searchlight
Board Regular
- Joined
- Dec 25, 2009
- Messages
- 112
I have this code to save 2 copies of my file when I close excel, one in the original folder and the other in a designated folder.
I have the file read-only and when the file is closed in the read only mode it gives a runtime error but still executes properly.
How do I get past the error so it does not show and goes directly to the normal read-only prompt?
Run-time error '1004':
'eRDL.xls' is read-only. To save a copy, click OK, then give the workbook a new name in the Save As dialog box.
Once you select End on the error message box it goes to the Save As prompt or closes.
Thanks!
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Note that any previous backup is overwritten
Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs Filename:="C:\Documents and Settings\My Documents\" & _
ActiveWorkbook.Name
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub
I have the file read-only and when the file is closed in the read only mode it gives a runtime error but still executes properly.
How do I get past the error so it does not show and goes directly to the normal read-only prompt?
Run-time error '1004':
'eRDL.xls' is read-only. To save a copy, click OK, then give the workbook a new name in the Save As dialog box.
Once you select End on the error message box it goes to the Save As prompt or closes.
Thanks!
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Note that any previous backup is overwritten
Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs Filename:="C:\Documents and Settings\My Documents\" & _
ActiveWorkbook.Name
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub