win32com ppt saveas, not allowing spaces?

L

Lance Hoffmeyer

Hey all,

As always, thanks in advance!


I am trying to save a ppt presentation but am having problems regarding spaces and am wondering
if I am doing something wrong or whether this is a bug? Also, is there a way around this other
than not using spaces in paths or filenames? I can create filesnames without spaces but don't have
much control over paths.

Lance


WB.SaveAs("C:/temp/00_FINAL." + time.strftime("%Y.%m.%d.(%I.%M.%S%p)", time.localtime()) + ".ppt")

saves the file C:\temp\00_FINAL.2007.07.16.(09.43.50AM).ppt


but

WB.SaveAs("C:/tmp dir/00_FINAL." + time.strftime("%Y.%m.%d.(%I.%M.%S%p)", time.localtime()) + ".ppt")

gives the error:

Traceback (most recent call last):
File "C:\temp\ppt.py", line 412, in ?
WB.SaveAs("C:/tmp dir/00_FINAL." + time.strftime("%Y.%m.%d.(%I.%M.%S%p)", time.localtime()) + ".ppt")
File "C:\Program Files\Python\lib\site-packages\win32com\gen_py\91493440-5A91-11CF-8700-00AA0060263Bx0x2x8.py", line 6827, in SaveAs
return self._oleobj_.InvokeTypes(2036, LCID, 1, (24, 0), ((8, 1), (3, 49), (3, 49)),FileName, FileFormat, EmbedTrueTypeFonts)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Office PowerPoint 2003', 'Presentation.SaveAs : The path or file name for C://tmp%20dir/00_FINAL.2007.07.16.(09.44.01AM).ppt is invalid. Please check that the path and file
name are correct.', '', 0, -2147467259), None)

Tool completed with exit code 1

Also,

WB.SaveAs("C:/temp/00 FINAL." + time.strftime("%Y.%m.%d.(%I.%M.%S%p)", time.localtime()) + ".ppt")

yields:

C:/temp/00%20FINAL.2007.07.16.(09.45.35AM).ppt



Lance
 
G

Gabriel Genellina

2. But problem is that I can't copy over if the same updated
personal geodatabase to the working location, if users uses that same
geodatabase through CITRIX - ArcGIS ( user does not have permission to
edit the data)

If you get an "Access denied" (or "File is in use by another process")
error, I'm afraid there is nothing you can do from Python. Tell the users
to close the application that holds the file open and try again.
import shutil
import os

src = "c:\mydata\test\mygeo.mdb"
dst = "v:\updated\data\mygeo.mdb"

Here you have another problem: \t inside a string means the TAB character.
You have to escape all backslashes or use a raw string:
that is, either use "c:\\mydata\\test\\mygeo.mdb" or
r"c:\mydata\test\mygeo.mdb"
 
Y

Yves Pouplard

2. But problem is that I can't copy over if the same updated
personal geodatabase to the working location, if users uses that same
geodatabase through CITRIX - ArcGIS ( user does not have permission to
edit the data)

why don't you use Unison ? nothing to do with Python...
look at http://www.cis.upenn.edu/~bcpierce/unison/

pls look for the command line version for windows, current version is
2.28.17, with a few tools from GnuWin32 if needed... :)
 
S

supercooper

import shutil
import os

src = "c:\mydata\test\mygeo.mdb"
dst = "v:\updated\data\mygeo.mdb"

shutil.copyfile(src,dst)

This should totally work, do it all the time, but no one can be
connected to the database, ie have ArcMap or ArcCatalog open at the
time of copy, or the .ldb lock will kill it. I do all of my copies in
the early AM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top