Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SaveAs Dialog appearing as expected but then not saving. 2

Status
Not open for further replies.

HairyHippy

Programmer
Aug 5, 2004
53
GB
The following piece of code displays the SaveAs dialog box, exactly as desired when run but when the save button is hit, the dialog box disappears and the file has not been saved with the new file name. Any ides
Code:
Sub SaveAs()
    Dim Filt As String
    Dim FileName As Variant
    Filt = "Microsoft Excel Workbook (*.xls),*.xls,"
    
    FileName = Application.GetSaveAsFilename(Range("SaveClient") + " - " + Range("Deal"), filefilter:=Filt)
    
End Sub
 
Adey.

The code does as you say, it displays the dialog box and sets the variable FileName to be the filename you require, but you don't then do anything with it.

You need a bit of extra code to actualy do the save

Code:
 ActiveWorkbook.SaveAs Filename:= filename

You will probably need tpo change your variable name from filename as well.
 
Something like this ?
Code:
Filt = "Microsoft Excel Workbook (*.xls), *.xls"    
FileName = Application.GetSaveAsFilename(Range("SaveClient") + " - " + Range("Deal"), Filt)
If FileName <> False Then
    ActiveWorkbook.SaveAs FileName
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks guys - is there anyway of getting the code to just save the file as the required name and type rather than displaying the SaveAs dialog box?
 
A starting point:
ActiveWorkbook.SaveAs Range("SaveClient") & " - " & Range("Deal") & ".xls"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try this

Application.Dialogs(xlDialogSaveAs).Show
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top