yorkshirelad
Board Regular
- Joined
- Aug 18, 2003
- Messages
- 100
I have a macro that automates the saving of a master file with a new version with today's date.
Sub SaveFileAs()
Dim file As String
file = "ClientData_" & Format(Now, "ddmmmyy") & ".xls"
ActiveWorkbook.SaveAs file
End Sub
If there is already an existing file I get the standard Windows warning asking if I want to overwrite the existing file - which is great.
However ....
If a file with the same name is already open the macro comes up with a Run-time error '1004'
"You cannot save this workbook with the same name as another open workbook or add-in. Choose a different name etc."
Apart from the confusion caused to the user seeing the macro error message. As this also means that the master file is still open with all the changes - which risks being overwritten (if the user clicks to save this file). Is there a way of the file being saved with an alternative filename e.g. Version1 etc - if another copy of the file is already open?
The other option would be if there was a macro that checked for a file already being open with the same name and if so asked them to close it, before they clicked the final save file macro.
Many thanks for any assistance provided - thanks
Sub SaveFileAs()
Dim file As String
file = "ClientData_" & Format(Now, "ddmmmyy") & ".xls"
ActiveWorkbook.SaveAs file
End Sub
If there is already an existing file I get the standard Windows warning asking if I want to overwrite the existing file - which is great.
However ....
If a file with the same name is already open the macro comes up with a Run-time error '1004'
"You cannot save this workbook with the same name as another open workbook or add-in. Choose a different name etc."
Apart from the confusion caused to the user seeing the macro error message. As this also means that the master file is still open with all the changes - which risks being overwritten (if the user clicks to save this file). Is there a way of the file being saved with an alternative filename e.g. Version1 etc - if another copy of the file is already open?
The other option would be if there was a macro that checked for a file already being open with the same name and if so asked them to close it, before they clicked the final save file macro.
Many thanks for any assistance provided - thanks