View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
marnie marnie is offline
external usenet poster
 
Posts: 16
Default Save copy of workbook

Dave
Thanks! That worked for a regular file name. However I am actually trying
to update a document on a Sharepoint site so the path name is a web address.
If I manually do a Save AS with the web address it works fine. If I put the
same web address in this code I get "Run-time error 1004. The file cannot be
found." Do you know if there is a limit to the number of characters that can
be used in a file name in this context?

Thanks
Marni

"Dave Peterson" wrote:

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