Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi everybody,
I would like to know how to run a macro any time a workbook is bein saved. I created my macro is saved in "Personal.xls" but I do not kno how to trigger it without using a button associated to it but instea when the user would click File-save or directly the save icon. I trie to add a call to my macro in the code of the event BeforeSave o "Personal.xls" but it does not work... Thanks to whoever can give me a hand on this. donbu -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You will need to create class event to trap the event of any open workbook
being saved. The class event can reside in your personal.zls. A good resource to read up on this is in chip pearson web site. url I think is www.cpearson.com as well do a googgle search on class events. to get you started..... Put the following in a new class module ' use insert class module from vbe rename it to EventClass Option Explicit Public WithEvents App As Application Private Sub App_WorkbookBeforeSave(ByVal wb As Workbook, Cancel As Boolean) ' your code end sub In this thisworkbook module of personal.xls Option Explicit Dim AppClass As EventClass Private Sub Workbook_Open() Set AppClass = New EventClass Set AppClass.App = Application End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Set AppClass.App = Nothing End Sub "donbuz " wrote in message ... Hi everybody, I would like to know how to run a macro any time a workbook is being saved. I created my macro is saved in "Personal.xls" but I do not know how to trigger it without using a button associated to it but instead when the user would click File-save or directly the save icon. I tried to add a call to my macro in the code of the event BeforeSave of "Personal.xls" but it does not work... Thanks to whoever can give me a hand on this. donbuz --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Changes to workbook not saved | Excel Discussion (Misc queries) | |||
The time the spreadsheet was saved | Excel Discussion (Misc queries) | |||
Macro run each time a new workbook created | Excel Discussion (Misc queries) | |||
How can I see a copy of a saved workbook before I saved it again? | Excel Worksheet Functions | |||
macro to time limit workbook | Excel Discussion (Misc queries) |