Hi,

I am wanting to display a file "Save As..." dialog in Excel through Pywin.
 I am doing this by calling
Application.GetSaveAsFilename<http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._application.getsaveasfilename.aspx>().
 The problem however is that the parameter supplied to this function,
InitialFilename, seems to be ignored by Excel.  Perhaps it's not getting
through to Excel.  When VBA was used to call the same function, the initial
filename displayed correctly.

Not being able to specify an initial filename is inconvenient if not
unsatisfactory from application usability point of view, and one wonders if
other functions might also be affected.   If anyone has any suggestions as
to why this might be happening, or even what a solution may be, I would be
glad to hear from you.

I am using Python 2.7 on Win 7, Office 2010 (v14), and a very recent stable
release of pywin (pywin32-216.win32-py2.7).

Code to recreate the problem:

app = Dispatch("Excel.Application")
app.Visible=True
books=app.Workbooks
books.Open(Filename="C:/temp/test.xlsx")
app.GetSaveAsFilename(InitialFilename="filename.xlsx")  # <<<<<<< THIS
PARAMETER IS IGNORED
app.Quit()

Pywin generated function for the GetSaveAsFilename function (in which it can
be seen that the parameter InitialFilename is handled):

def GetSaveAsFilename(self, InitialFilename=defaultNamedOptArg,
FileFilter=defaultNamedOptArg, FilterIndex=defaultNamedOptArg,
Title=defaultNamedOptArg
, ButtonText=defaultNamedOptArg):
return self._ApplyTypes_(1076, 1, (12, 0), ((12, 17), (12, 17), (12, 17),
(12, 17), (12, 17)), u'GetSaveAsFilename', None,InitialFilename
, FileFilter, FilterIndex, Title, ButtonText)

At the moment, development is stopped in its tracks, so comments are greatly
appreciated.

Thanks

Jason
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to