mpearce
04-17-2009, 08:36 AM
I am using the below script to automatically save a workbook to a folder with a hard coded name. This is fine if the file doesn't exist, but if it does i want the user to be able to save it as something else.
This script does prompt me saying the file exists, would you like to replace it? If i say yes things are fine, but if i say no i get an error "Method 'SaveAs' of object '_workbook' failed.
My question is if the user says no how can i get a save as dialog box to appear?
here is my code:
Sub saveas(ByRef date1 As String)
date1 = Format(Date, "MM-DD-YYYY")
Application.Workbooks(2).Activate
ActiveWorkbook.saveas Filename:="C:\deco\Inova Recon " & date1, FileFormat:=xlNormal, Password:="", _
WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close False
End Sub
This script does prompt me saying the file exists, would you like to replace it? If i say yes things are fine, but if i say no i get an error "Method 'SaveAs' of object '_workbook' failed.
My question is if the user says no how can i get a save as dialog box to appear?
here is my code:
Sub saveas(ByRef date1 As String)
date1 = Format(Date, "MM-DD-YYYY")
Application.Workbooks(2).Activate
ActiveWorkbook.saveas Filename:="C:\deco\Inova Recon " & date1, FileFormat:=xlNormal, Password:="", _
WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close False
End Sub