GetSaveAsFilename not working under Windows 7 OS

L33

Board Regular
Joined
Jul 2, 2008
Messages
108
Hi,

I have a piece of VBA that works perfectly well under a Windows XP operating system, but we've just had Windows 7 installed at work and now it won't work properly:

Code:
FileSaveName = Application.GetSaveAsFilename(myReportStore & "\" & CorporateName & ".xlsm")
        
ActiveWorkbook.SaveAs FileSaveName

The Save As dialog box no longer automatically has the suggested file name (ie."CorporateName.xlsm") in the "File Name" field, and also the "Save As Type" dropdown beneath it contains a single option which reads "All Files (*.*)"

If I manually type in a name I have to include the ".xlsm" extension - but I don't want my users to have to remember to do this. I want them to be presented with the suggested filename in the suggested path.

Any suggestions as to what needs tweaking? :confused:
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi Trevor,
I had that originally but wanted a way of suggesting to the user the best path and filename to save the file in, which this method won't do. Earlier in my code I create the required folder structure and then store that in the variable "myReportStore". The Save As dialog in my code is still taking me there, but I also want the suggested file name in the box too, ideally.
 
Upvote 0
Then what about a userform to do this?

You could default the path (folder) and also suggested file name in a textbox.

ALmost Mimicking the SaveAs<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
 
Upvote 0
Excellent! Had a bit of trouble working out how to default as an ".xslm" in the dialog but got it working (FilterIndex=2 !). I wonder what it is about Windows 7 that makes my old method invalid...

Many thanks for your help, Richard.
 
Upvote 0
For benefit of future Googlers and messageboard searchers with same problem:

Original code:
Code:
FileSaveName = Application.GetSaveAsFilename(myReportStore & "\" & CorporateName & ".xlsm")
        
ActiveWorkbook.SaveAs FileSaveName

New code:
Code:
    Dim FileSaveName As FileDialog
    
    Set FileSaveName = Application.FileDialog(msoFileDialogSaveAs)
    
    FileSaveName.InitialFileName = myReportStore & "\" & CorporateName
    FileSaveName.FilterIndex = 2   'select to save with a ".xlsm" extension
    FileSaveName.Show
    FileSaveName.Execute

Thanks to Richard Schollar for the idea.
 
Upvote 0
I doubt you are going to get much luck here... Perhaps you should ask at a JavaScript forum...
 
Upvote 0

Forum statistics

Threads
1,226,225
Messages
6,189,735
Members
453,566
Latest member
ariestattle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top