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

Hi All,
How do i exactly trap the close event of a excel workbook. I need to now the
name of the workbook which is closed. I tried using Workbook_BeforeClose
event.But if the user presses cancel this event is of no use. Then i went
though the Pearson events http://www.cpearson.com/excel/events.htm tutorial
and combined Window_Deactivate and Beforeclose to get exactly the close
event.When there multiple worksheets open this method also fails. Could any
one tell exact way to catch this event.Any code available would be grateful

Thanks in advance

Thanks
Xcelion




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel WorkBook Close Event

Try something like this in ThisWorkbook

Public WithEvents App As Application

Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
MsgBox Wb.Name
End Sub

Private Sub Workbook_Open()
Set App = Application
End Sub


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Xcelion" wrote in message
...
Hi All,
How do i exactly trap the close event of a excel workbook. I need to now

the
name of the workbook which is closed. I tried using Workbook_BeforeClose
event.But if the user presses cancel this event is of no use. Then i went
though the Pearson events http://www.cpearson.com/excel/events.htm

tutorial
and combined Window_Deactivate and Beforeclose to get exactly the close
event.When there multiple worksheets open this method also fails. Could

any
one tell exact way to catch this event.Any code available would be

grateful

Thanks in advance

Thanks
Xcelion






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Excel WorkBook Close Event

Hi Bob,
Thanks for you reply
This method also ,fires before the user is prompted to save changes. So i
will get
the close event even if the user presses the cancel button.How to avoid
this.If the user presses the cancel i shouldn't get the close event

Awaiting for your reply
Thanks
Xcelion


"Bob Phillips" wrote:

Try something like this in ThisWorkbook

Public WithEvents App As Application

Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
MsgBox Wb.Name
End Sub

Private Sub Workbook_Open()
Set App = Application
End Sub


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Xcelion" wrote in message
...
Hi All,
How do i exactly trap the close event of a excel workbook. I need to now

the
name of the workbook which is closed. I tried using Workbook_BeforeClose
event.But if the user presses cancel this event is of no use. Then i went
though the Pearson events http://www.cpearson.com/excel/events.htm

tutorial
and combined Window_Deactivate and Beforeclose to get exactly the close
event.When there multiple worksheets open this method also fails. Could

any
one tell exact way to catch this event.Any code available would be

grateful

Thanks in advance

Thanks
Xcelion







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
Workbook-Close StopTimer event Stonewall Rubberbow Excel Discussion (Misc queries) 2 January 12th 08 11:06 PM
Workbook Before Close Event Cancel flag not functional(?) Kristian Mayville Excel Programming 0 July 21st 05 02:46 PM
EXCEL close event? bmm Excel Programming 1 November 9th 04 01:51 PM
Workbook Close Event Stefano Condotta Excel Programming 1 June 16th 04 10:44 PM
Clear Clipboard on Workbook Close Event (Excel XP) Culichi Excel Programming 2 February 23rd 04 06:21 PM


All times are GMT +1. The time now is 12:38 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"