GetSaveAsFilename - file name is blank

  • Thread starter Thread starter JanetJek
  • Start date Start date
J

JanetJek

I have an Excel macro that prompts the user for the file name with
GetSaveAsFilename. It works fine under Window XP (Excel 2000, 2003, 2007)
but with Excel 2007 and Vista, the file name in the prompt box is empty,
blank. There is no file name.

Any suggestions?
 
Hi Janet

This is working for me in Vista/O2007

Dim fname As Variant
fname = Application.GetSaveAsFilename(InitialFileName:="test.xlsm", _
fileFilter:="Excel Files (*.xlsm), *.xlsm")
 
It looks like if you do not provide the FileFilter argument, the InitialFile
argument is ignored. This, of course, is different than with XL2003.

Rick
 
Remove the fileFilter argument and you will see what the OP is writing
about... apparently XL2007 changed something as XL2003 works fine with just
the InitialFile argument.

Rick
 
And, of course, it makes good sense to **always** use FileFilter (OP please
take note)... I am not sure why Microsoft decided to change
GetSaveAsFilename in XL2007 making the display of InitialFile contingent on
its use though.

Rick
 
Thanks for the heads up Ron,

However; I have that code implemented, but I am receiving an error message
(file format or extension) when I try to re-open the file.

Any thoughts? Thanks ~ Stephen

here is the code on 1 line ...

fName = Application.GetSaveAsFilename(InitialFileName:="test.xlsm",
FileFilter:="Excel Files (*.xlsm), *.xlsm")
 
The situation is more bizarre than presented. I was still getting the problem even with using filefilters argument

I was trying to save an xlt file with the following:

filefilter:="Template (*.xlt; *.xltm; *.xltx), *.xlt; *.xltm; *.xltx"

This works perfectly well on XL 2003. However on 2007 the initial filename would be blank

I discovered after some time that the initial filename extension must match the final file filter before it will be displayed

so this works on 2007:

filefilter:="Template (*.xltx; *.xltm; *.xlt), *.xltx; *.xltm; *.xlt"
 
Thanks for the hint. Just trying to tidy up an old Excel macro. (Which probably worked under Excel 2003 and 2007 but not under 2010).

I found that, not only does the filename need to have the same extension, the extension needs to be in the SAME CASE too!
 
Back
Top