win32com ppt saveas, not allowing spaces?

Lance Hoffmeyer lance at
Mon Jul 16 16:49:14 CEST 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.


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


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\", 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\", 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


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




More information about the Python-list mailing list