Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your code worked ok for me. Are you sure you let the procedure finish?
Option Explicit Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim strPrompt As String Dim intButtons As Integer Dim strTitle As String With Me ' save a copy in public folder in power vault On Error Resume Next .SaveCopyAs ("\\Powervault\Global Schedule BU\" & .Name) ' if error occurs notify user If Err.Number < 0 Then err.clear strPrompt = "The back up file for " & .Name _ & " was not saved in '\\Powervault\Global Schedule BU' folder." strPrompt = strPrompt _ & " Please make a note of this and notify Ryan." intButtons = vbExclamation strTitle = "Problem" MsgBox strPrompt, intButtons, strTitle End If on error goto 0 End With End Sub The code I posted has minor changes. Since the code is in the ThisWorkbook module, I used the Me keyword instead of ThisWorkbook. And since you were using the with/end with structure, I removed the qualifiers from some of the properties you used. RyanH wrote: I have a workbook that I would like to save a copy to a different location everytime I save the workbook. I use the BeforeSave Event. The copy saves perfectly but it doesn't save to its original folder, why? Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim strPrompt As String Dim intButtons As Integer Dim strTitle As String On Error Resume Next With ThisWorkbook ' save a copy in public folder in power vault .SaveCopyAs ("\\Powervault\Global Schedule BU\" & ThisWorkbook.Name) ' if error occurs notify user If Err.Number 0 Then strPrompt = "The back up file for " & ThisWorkbook.Name & " was not saved in '\\Powervault\Global Schedule BU' folder." strPrompt = strPrompt & " Please make a note of this and notify Ryan." intButtons = vbExclamation strTitle = "Problem" MsgBox strPrompt, intButtons, strTitle End If End With End Sub -- Cheers, Ryan -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Beforesave - Save copy on my desktop | Excel Programming | |||
Protect Worksheet / Workbook in BeforeSave Event | Excel Programming | |||
Save method and BeforeSave event | Excel Programming | |||
BeforeSave sub won't save another workbook when triggered by another event sub | Excel Programming | |||
BeforeSave workbook event | Excel Programming |