Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trapping Excel Close Event

Can anyone help with trapping the application.quit event
that is triggered by clicking on the close (X) box in the
upper right title bar or when the user performs a
File_Exit command and there is no Save Box genereated?
Workbook_close and _Deactivate do not seem to work.

Thanks

Bob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Trapping Excel Close Event

Bob,

There is no Application Close or BeforeClose event. However, you can trap the Before_Close event for a workbook that results from
the closure of the application. You can do this for all open workbooks by trapping application events. Try placing the following
code in the ThisWorkbook module of a workbook such as Personal.xls:

Option Explicit

Dim WithEvents xlApp As Excel.Application

Private Sub Workbook_Open()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
'Do stuff
End Sub

"Do stuff" will be executed when any workbook is closed and can include setting Cancel = True to prevent the closure of the workbook
and the application.

--

John Green - Excel MVP
Sydney
Australia


"Bob J." wrote in message ...
Can anyone help with trapping the application.quit event
that is triggered by clicking on the close (X) box in the
upper right title bar or when the user performs a
File_Exit command and there is no Save Box genereated?
Workbook_close and _Deactivate do not seem to work.

Thanks

Bob




  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Trapping Excel Close Event


-----Original Message-----
Can anyone help with trapping the application.quit event
that is triggered by clicking on the close (X) box in

the
upper right title bar or when the user performs a
File_Exit command and there is no Save Box genereated?
Workbook_close and _Deactivate do not seem to work.

Thanks

Bob
Thanks, your code worked!


Bob

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trapping Excel Close Event

As replied to the previous posting of this question:

There is no event fired for Excel itself closing. You can trap workbooks
closing with the BeforeClose Event. It sounds like you want this done at
the application level, so you would need to instantiate application level
events. See Chip Pearson's page on this

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

--
Regards,
Tom Ogilvy


Bob J. wrote in message
...
Can anyone help with trapping the application.quit event
that is triggered by clicking on the close (X) box in the
upper right title bar or when the user performs a
File_Exit command and there is no Save Box genereated?
Workbook_close and _Deactivate do not seem to work.

Thanks

Bob




Reply
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
before close event with condition mohavv Excel Discussion (Misc queries) 4 November 21st 07 03:14 AM
trapping charts event PLP Charts and Charting in Excel 2 June 21st 07 01:18 AM
Trapping Excel Close event Bob J[_2_] Excel Programming 3 December 5th 03 11:56 PM
Excel main window close event Avneesh Saxena Excel Programming 2 November 21st 03 07:42 PM
After Close Event? Don Wiss Excel Programming 2 November 19th 03 12:30 AM


All times are GMT +1. The time now is 02:44 AM.

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

About Us

"It's about Microsoft Excel"