win32com ppt saveas, not allowing spaces?

Lance Hoffmeyer lance at augustmail.com
Mon Jul 16 10:49:14 EDT 2007


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



More information about the Python-list mailing list