ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Running a macro "On Save" (https://www.excelbanter.com/excel-discussion-misc-queries/89262-running-macro-save.html)

heski

Running a macro "On Save"
 

Hi,

Can anyone tell me how I can get a file to run a macro each time the
file is saved. I know this is achievable but can't find how to do it.

Thanks in advance for any assistance.


--
heski
------------------------------------------------------------------------
heski's Profile: http://www.excelforum.com/member.php...o&userid=30581
View this thread: http://www.excelforum.com/showthread...hreadid=543201


papou

Running a macro "On Save"
 
Hello
Use this workbook event which fires before saving workbook :
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Not Cancel Then
'do your stuff here
End If
End Sub

To acces this event either right-click on the Excel icon immediately
situated left to th File Menu in Excel
or open VB Editor and double-click on Thisworkbook

HTH
Cordially
Pascal

"heski" a écrit dans le
message de news: ...

Hi,

Can anyone tell me how I can get a file to run a macro each time the
file is saved. I know this is achievable but can't find how to do it.

Thanks in advance for any assistance.


--
heski
------------------------------------------------------------------------
heski's Profile:
http://www.excelforum.com/member.php...o&userid=30581
View this thread: http://www.excelforum.com/showthread...hreadid=543201




CLR

Running a macro "On Save"
 

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

Vaya con Dios,
Chuck, CABGx3


"heski" wrote:


Hi,

Can anyone tell me how I can get a file to run a macro each time the
file is saved. I know this is achievable but can't find how to do it.

Thanks in advance for any assistance.


--
heski
------------------------------------------------------------------------
heski's Profile: http://www.excelforum.com/member.php...o&userid=30581
View this thread: http://www.excelforum.com/showthread...hreadid=543201




All times are GMT +1. The time now is 11:16 PM.

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