Running a macro before saving file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I run a macro automatically right before saving a file. So all the user had to do is to click on save and the macro will run.?

Thank
E.B.
 
There is a workbook event called BeforeSave. Call you macro in this event
code.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Einollah2001 said:
How can I run a macro automatically right before saving a file. So all the
user had to do is to click on save and the macro will run.??
 
Hi
you can use the workbook Beforesave event. enter the following in your
workbook module
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Msgbox "Will save now"
'enter your code here
End Sub

Frank
 
Here is what you need to do

1) in the project explorer window, click on "This Worbook"

2) Select "Workbook" in the objects dropdown list

3) Select "BeforeSave" in the events list.

4) the following headers should appear automatically

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

End Sub

insert all code between these lines. IF you want to call a procedur
simply type in

call (procedure name
 
Back
Top