SaveAs

D

Daviv

I have the following code:

FName = Application.GetSaveAsFilename(InitFileName, "Excel File
(*.xls),*.xls")
ActiveWorkbook.SaveAs FName, CreateBackup = False

When I cancel the save, I get a "FALSE" file. I believe this is a backup
file so I set Createbackup = false. But no luck. Thanks in advance.
 
J

Jim Thomlinson

If you cancel Application.GetSaveAsFilename the it returns "FALSE". You need
to check for this before saving

FName = Application.GetSaveAsFilename(InitFileName, "Excel File
(*.xls),*.xls")
if FName <> "FALSE then
ActiveWorkbook.SaveAs FName, CreateBackup = False
end if
 
C

Chip Pearson

Declare FName as a Variant and test it for False (not "False"). E.g.,

Dim FName As Variant
FName = Application.GetSaveAsFilename(....)
If FName = False Then
Debug.Print "User Cancelled"
Else
Debug.Print "Filename: " & FName
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Case Event 2
Case Select 2
Before Save 1
Hiding an Excel file using VBA 1
Simplify save code 11
xltm saveas xlsm 6
Original read only file not closing 0
Command Button to export a worksheet as a .csv file 1

Top