ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a macro before saving file (https://www.excelbanter.com/excel-programming/290810-running-macro-before-saving-file.html)

Einollah2001

Running a macro before saving file
 
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.

Bob Phillips[_6_]

Running a macro before saving file
 
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" wrote in message
...
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.??

Thanks
E.B.




Frank Kabel

Running a macro before saving file
 
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

Einollah2001 wrote:
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.??

Thanks
E.B.




mahesh

Running a macro before saving file
 
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

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Running a macro before saving file
 
Use the BeforeSave event

Not familiar with events? See Chip Pearson's page on the topic

http://www.cpearson.com/excel/events.htm

--
regards,
Tom Ogilvy


Einollah2001 wrote in message
...
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.??

Thanks
E.B.





All times are GMT +1. The time now is 08:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com