View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default VBA for file save as

Declare sFileName as a Variant, not a String, and test its value
for False. E.g.,

Dim Fame As Variant
FName = Application.GetSaveAsFilename("", "Excel Files
(*.xls),*.xls")
If FName = False Then
Debug.Print "user clicked cancel"
Else
Debug.Print "user chose " & FName
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"SharonP." wrote in message
...
When I use the following code, the File/Save As Windows dialog
box opens and
as long as a file name is supplied - the file saves properly.
However, if
you click Cancel and don't provide a file name - a false.xls
file is created.
Is there a way to avoid this? What I want is just for the save
as function
to cancel without a save.

'Prompts to save the TLR file with the appropriate name

ChDir "U:\ACTUARIAL\Renewals"
sFilename = Application.GetSaveAsFilename("", "excel files
(*.xls),*.xls")
ActiveWorkbook.SaveAs Filename:=sFilename