Intercepting the Save

  • Thread starter Thread starter Dennis Tucker
  • Start date Start date
D

Dennis Tucker

I want to run a little code when the user saves the workbook. How can I
intercept the Save command?


Dennis
 
From workbook press Alt+F11 to launch VBE (Visual Basic Editor). From the
left treeview search for the workbook name and click on + to expand it.
Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Msgbox "Cannot Save"
'to cancel the save
Cancel = True
End Sub

If this post helps click Yes
 
Back
Top