ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto run macro when file is saved (https://www.excelbanter.com/excel-programming/419809-auto-run-macro-when-file-saved.html)

Rob

Auto run macro when file is saved
 
Hi,
Is there a way to auto run a macro everytime a file is saved? I am using the
code below to add a revision date into the footer. I need this to execute
every time the file is saved.
Thanks.

Function MyDate()
Application.Volatile
MyDate = FileDateTime(ThisWorkbook.FullName)
End Function

Sub setfooterfromrange()

With ActiveSheet.PageSetup
ActiveWorkbook.Save
.LeftFooter = "Revision Date: " & Format(Range("z64"), "Dddd, Mmmm dd,
yyyy, h:mm AM/PM")

End With

Don Guillett

Auto run macro when file is saved
 
Look in the ThisWorkbook moduleworkbookBeforeSave


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rob" wrote in message
...
Hi,
Is there a way to auto run a macro everytime a file is saved? I am using
the
code below to add a revision date into the footer. I need this to execute
every time the file is saved.
Thanks.

Function MyDate()
Application.Volatile
MyDate = FileDateTime(ThisWorkbook.FullName)
End Function

Sub setfooterfromrange()

With ActiveSheet.PageSetup
ActiveWorkbook.Save
.LeftFooter = "Revision Date: " & Format(Range("z64"), "Dddd, Mmmm dd,
yyyy, h:mm AM/PM")

End With




All times are GMT +1. The time now is 10:13 PM.

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