D
Don Lloyd
Hi All,
Happy New Year - belated but well meant
I'm programmatically using the SaveAs Dialog Box to allow the user to decide
where to save a file.
If the chosen path already exists, SaveAs points this out.
Fine, except that, if the option to not overwrite the file is chosen, an
error 1004 message appears. Clicking Help helpfully displays a blank Help
screen.
In short, how do I handle this error. Code example as follows.
Sub UserFileSave()
Dim Fname, Suggestion, Hdr
Suggestion = "MyFile " & Format(Date, "dd mmm yy")
Hdr = "Please choose a Location and Name then click Save."
Fname = Application.GetSaveAsFilename(Suggestion, fileFilter:="Excel File
(*.xls), *.xls)", Title:=Hdr)
If Fname = False Then
'Handle Cancel
UserCancel
Else
ThisWorkbook.SaveAs FileName:=Fname
End If
End Sub
Regards,
Don
( XL97 Win98 / XL2003 WinXp )
Happy New Year - belated but well meant
I'm programmatically using the SaveAs Dialog Box to allow the user to decide
where to save a file.
If the chosen path already exists, SaveAs points this out.
Fine, except that, if the option to not overwrite the file is chosen, an
error 1004 message appears. Clicking Help helpfully displays a blank Help
screen.
In short, how do I handle this error. Code example as follows.
Sub UserFileSave()
Dim Fname, Suggestion, Hdr
Suggestion = "MyFile " & Format(Date, "dd mmm yy")
Hdr = "Please choose a Location and Name then click Save."
Fname = Application.GetSaveAsFilename(Suggestion, fileFilter:="Excel File
(*.xls), *.xls)", Title:=Hdr)
If Fname = False Then
'Handle Cancel
UserCancel
Else
ThisWorkbook.SaveAs FileName:=Fname
End If
End Sub
Regards,
Don
( XL97 Win98 / XL2003 WinXp )