LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Handling the WorkbookAfterSave Event in VBA

Hi Chip,

I tried this, but WorkbookAfterSave isn't listed in the dropdown list of
events for XLApp. I see WorkbookBeforeSave, WorkbookAfterXmlImport, and a
few dozen other events, but not WorkbookAfterSave.

I'm using Excel 2007. Do I need Excel 2010?

Thanks.

Steve

"Chip Pearson" wrote in message
...
Because application events are for all open workbooks, you need to use
the WorkbookAfterSave event, which is called when any workbook is
saved. The WB parameter references the workbook that was saved.

E.g., in Class1,

Public WithEvents XLApp As Excel.Application

Private Sub Class_Initialize()
Set XLApp = Application
End Sub

Private Sub Class_Terminate()
Set XLApp = Nothing
End Sub

Private Sub XLApp_WorkbookAfterSave(ByVal Wb As Workbook, _
ByVal Success As Boolean)
MsgBox "AfterSave: " & Wb.Name
End Sub

Then, in ThisWorkbook:

Private XLEvents As Class1

Private Sub Workbook_Open()
Set XLEvents = New Class1
End Sub

As long as the workbook containing this code remains open, you'll get
WorkbookAfterSave events when any workbook is saved.


Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com





On Sun, 16 May 2010 15:00:33 -0400, "Steve Flaum"
wrote:

I can handle the Excel WorkbookAfterSave event in VB 2010 as explained at
http://msdn.microsoft.com/en-us/libr...ffice.14).aspx.
I
can also handle built-in events of the Excel application in VBA as
described
at http://msdn.microsoft.com/en-us/libr...ffice.10).aspx.
However, I cannot figure out how to handle the WorkbookAfterSave event in
VBA. If I use a statement such as:

Private WithEvents ExcelApp as Application

a number of application events are available, but WorkbookAfterSave isn't
one of them.

I suppose I could create a VB 2010 component which catches and rethrows
the
event, but there must be a better way. Can anyone tell me what it is?

Thanks.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling the WorkbookAfterSave Event in VBA Steve Flaum Excel Programming 0 May 17th 10 10:38 PM
checkbox event handling function nevwalters Excel Worksheet Functions 2 May 16th 06 04:27 AM
Changing RightClick event handling GeyserPeak[_2_] Excel Programming 1 July 27th 05 04:39 AM
Event handling... Alex Excel Programming 1 January 29th 05 06:24 PM
excel object event handling Vladimir Kryachko Excel Programming 1 September 9th 04 08:01 AM


All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"