Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Setting Application.EnableEvents=True after Thisworkbook.Close call

Is there anyway to get excel to re-enable application events after i
close a workbook.

Right now I have in some code:

Application.EnableEvents = False
ThisWorkbook.Close
Application.EnableEvents = True

However, the enableevents never gets set back to true as the sub stops
running when excel closes. Any help is appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Setting Application.EnableEvents=True after Thisworkbook.Close call

John,

I'm assuming that you don't want to run the Workbook_BeforeClose event: include code like this at
the top of the Workbook_BeforeClose event:

If boolDontRun Then Exit Sub

Declare a global variable in a standard codemodule:

Public boolDontRun As Boolean

Then instead of

Application.EnableEvents = False
ThisWorkbook.Close
Application.EnableEvents = True

Use

boolDontRun = True
ThisWorkbook.Close

HTH,
Bernie
MS Excel MVP


"John Fuller" wrote in message
ups.com...
Is there anyway to get excel to re-enable application events after i
close a workbook.

Right now I have in some code:

Application.EnableEvents = False
ThisWorkbook.Close
Application.EnableEvents = True

However, the enableevents never gets set back to true as the sub stops
running when excel closes. Any help is appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Setting Application.EnableEvents=True after Thisworkbook.Close call

That's what I have done, was just hoping there was a way of avoiding
the global variable (just a rule I have, the always seem to cause
problems). Thanks though.

Bernie Deitrick wrote:
John,

I'm assuming that you don't want to run the Workbook_BeforeClose event: include code like this at
the top of the Workbook_BeforeClose event:

If boolDontRun Then Exit Sub

Declare a global variable in a standard codemodule:

Public boolDontRun As Boolean

Then instead of

Application.EnableEvents = False
ThisWorkbook.Close
Application.EnableEvents = True

Use

boolDontRun = True
ThisWorkbook.Close

HTH,
Bernie
MS Excel MVP


"John Fuller" wrote in message
ups.com...
Is there anyway to get excel to re-enable application events after i
close a workbook.

Right now I have in some code:

Application.EnableEvents = False
ThisWorkbook.Close
Application.EnableEvents = True

However, the enableevents never gets set back to true as the sub stops
running when excel closes. Any help is appreciated.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting Application.EnableEvents=True after Thisworkbook.Close call

I think this may help u

write this code in the workbook_windowdeactivate event
Application.EnableEvents = True

regards
murali




John Fuller wrote:
Is there anyway to get excel to re-enable application events after i
close a workbook.

Right now I have in some code:

Application.EnableEvents = False
ThisWorkbook.Close
Application.EnableEvents = True

However, the enableevents never gets set back to true as the sub stops
running when excel closes. Any help is appreciated.


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
Application.EnableEvents DCPan Excel Worksheet Functions 3 October 18th 08 05:46 AM
Call Application.Volatile(True) NOT WORKING FARAZ QURESHI Excel Discussion (Misc queries) 1 May 8th 08 04:50 AM
Application.EnableEvents = true, but no event fires Wexler Excel Programming 0 October 19th 04 06:08 PM
Application.EnableEvents Terry Excel Programming 2 April 2nd 04 08:25 PM


All times are GMT +1. The time now is 05:59 PM.

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"