PDA

View Full Version : beforeclose, saving the workbook



choubix
07-09-2008, 06:10 PM
hello again,

in the Beforeclose event handler I have this:


Dim Wk As Workbook
Set Wk = Workbooks("02 Output.xls")
If Wk.ReadOnly = False Then
Call Save_msg
End If

then the sub Save_msg is shows up a message box: if the user decides to save the workbook I am calling the sub: Save_wb



Dim Wk As Workbook
Set Wk = Workbooks("02 Output.xls")
Application.DisplayAlerts = False
Wk.SaveAs Filename:="P:/Product Monitors/Backup/02 Output.xls"
Call Backup_msg


the thing is: even though I have R/Write privileges Excel returns an errors saying that the file is write protected... any idea why? (i can use a Ctrl + S to save though without any problem)

any idea on what's going wrong ??

thanks for your help!

Simon Lloyd
07-10-2008, 12:44 PM
For a start you have the file switch set wrong!

Dim Wk As Workbook
Set Wk = Workbooks("02 Output.xls")
Application.DisplayAlerts = False
Wk.SaveAs Filename:="P:/Product Monitors/Backup/02 Output.xls"
Call Backup_msg
should look like:

Dim Wk As Workbook
Set Wk = Workbooks("02 Output.xls")
Application.DisplayAlerts = False
Wk.SaveAs Filename:="P:\Product Monitors\Backup\02 Output.xls"
Call Backup_msg