Save copy of workbook
When you go into the VBE, double click on the ThisWorkbook object (in the
project explorer).
Then use the dropdowns at the top of the code window and choose Workbook. Then
use the righthand side dropdown to choose BeforeSave, you'll see that the event
isn't what you called it.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
You can't make events up, so it's much better/safer to use those dropdowns to
get the correct event and arguments.
Marnie wrote:
I need to save a duplicate copy of a workbook each time it is saved,
overwritting the duplicate. I tried this code and it did not work. No
errors but it did not create the copy.
Private Sub Worksheet_beforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ActiveWorkbook.SaveCopyAs "g:\EHSAdr.xls"
End Sub
Thanks!
--
Dave Peterson
|