Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect Save or Save As Event in Excel to run a macro. 1

Status
Not open for further replies.

Goska

Programmer
Jun 21, 2001
74
US
I think the subject was descriptive enough of my question. I want to be able to intercept a Save or SaveAs that the user is trying to do from the File menu for a portion of my program, so they don't try to overwrite the main file that I have. Thanks in advance.
 
In the ThisWorkbook object, use the following event:


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

If (you want to forbid saving) Then
Cancel = True
End If

End Sub
 
Perfect. I had been playing with that same code from the help files and just couldn't get it quite right. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top