How do I run macro WHENEVER a file is saved?


Posted by JAF on November 30, 1999 7:37 AM

I have a macro which checks a spreadsheet for errors and I want to run this EVERY time a user saves the file, but before the workbook is closed.

I'm sure this is one of those "obvious" bits of code, but I've been trying to sort it all day and it's starting to get annoying!

TIA - JAF



Posted by Ivan Moala on December 01, 1999 12:09 AM

Assuming xl97
Try;

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.Run ("test")
End Sub

where test is the name of your macro
The above routine should be placed in your
"Thisworkbook" VBA project object module


Ivan