That was it - invoking the function with the FileFilter parameter as well
resulted in the display of the InitialFilename as desired.  Your googling
has saved my day. Many thanks Andrew.

I might say though, that googling on Excel in general seems to bring up a
lot of noisy hits, but more to the point one would not expect the display of
InitialFilename to depend on filter specification especially as it wasn't
required in VBA and it isn't mentioned in Microsoft's documentation of the
function.



On Wed, Jul 13, 2011 at 8:00 PM, <python-win32-requ...@python.org> wrote:

> Send python-win32 mailing list submissions to
>        python-win32@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.python.org/mailman/listinfo/python-win32
> or, via email, send a message with subject or body 'help' to
>        python-win32-requ...@python.org
>
> You can reach the person managing the list at
>        python-win32-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of python-win32 digest..."
>
>
> Today's Topics:
>
>   1. Calling Excel function GetSaveAsFilename, parameter ignored
>      (Jason Veldicott)
>   2. Re: Calling Excel function GetSaveAsFilename, parameter
>      ignored [SEC=PERSONAL] (Andrew MacIntyre)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 13 Jul 2011 16:36:24 +1000
> From: Jason Veldicott <jasonveldic...@gmail.com>
> To: python-win32@python.org
> Subject: [python-win32] Calling Excel function GetSaveAsFilename,
>        parameter ignored
> Message-ID:
>        <CAK4NeTGs=14mT8sD7Hgn2XjUD-sjtKv=j0b4flupkl6zfjw...@mail.gmail.com
> >
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/python-win32/attachments/20110713/c0173b52/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Wed, 13 Jul 2011 07:50:01 +0000
> From: "Andrew MacIntyre" <andrew.macint...@acma.gov.au>
> To: "python-win32@python.org" <python-win32@python.org>
> Subject: Re: [python-win32] Calling Excel function GetSaveAsFilename,
>        parameter ignored [SEC=PERSONAL]
> Message-ID:
>
>  <a1e4e9d08d14924498e135fb4441ee8d07196...@act01exmbx01vp.internal.govt>
>
> Content-Type: text/plain; charset=iso-8859-1
>
> > From:  Jason Veldicott
> >
> > I am wanting to display a file "Save As..." dialog in Excel through
> Pywin. ?I am doing
> > this by calling?Application.GetSaveAsFilename(). ?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.
>
> Some googling turned up
> http://www.officekb.com/Uwe/Forum.aspx/excel-prog/137292/GetSaveAsFilename-file-name-is-blank
> which might be related to what you're seeing.
>
> -------------------------> "These thoughts are mine alone!" <---------
> Andrew MacIntyre           Operations Branch
> tel:   +61 2 6219 5356     Communications Infrastructure Division
> fax:   +61 2 6253 3277     Australian Communications & Media Authority
> email: andrew.macint...@acma.gov.au            http://www.acma.gov.au/
>
>
> NOTICE: This email message is for the sole use of the intended recipient(s)
>  and may contain confidential and privileged information. Any unauthorized
>  review, use, disclosure or distribution is prohibited. If you are not the
>  intended recipient, please contact the sender by reply email and destroy
> all
>  copies of the original message.
>
>
> ------------------------------
>
> _______________________________________________
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
> End of python-win32 Digest, Vol 100, Issue 14
> *********************************************
>
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to