Triggering an Excel macro on press of SAVE

  • Thread starter Thread starter darshan
  • Start date Start date
D

darshan

Hi,

I want to perform some check before saving an excel worksheet.
If the check is successful, then only should the worksheet be
saved, else i'd like to give a simple error message.

Could someone tell me if it is possible to trigger
an excel macro (developed by the user) when the
standard SAVE button on the toolbar is pressed ?
and within that i'd like to call the standard SAVE functionality
once my checks are successful.

Thanks in advance,
Darshan
 
Darshan,

Look at the BeforeSave event. It's in module ThisWorkbook. You have to
change the object (left) dropdown from (General) to Workbook, then in the
Procedure (right) dropdown, select BeforeSave. You'll see

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

End Sub

Put your code in there.

Earl Kiosterud
mvpearl omitthisword at verizon period net
 
sure you can

in the VB editor, select the Workbook in proj. explorer.

in the code editor, select 'workbook' as the object, then select the
'before save' event

then you may put your checks in there
 
Back
Top