Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default event that cannot be disabled?

I turn events off and then back on... usually.

If I fail to re-enable them, is there an event that persists? Is there an event that will fire every time?

I ask because I have to set something up to allow the user to re-enable events I messed up. (or screen updating, or automatic cal ...)

Thank you

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default event that cannot be disabled?


On Error GoTo EventsOn



Very good suggestion. Thanks.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default event that cannot be disabled?

In addition to Claus' good advice to impliment an error handler in your
complex routines, it sounds like you need a methodology in place to
properly manage Excel events!

I use the following mechanism to ensure only 1 routine has control of
Excel's events until that routine is done with them. This ensures
another routine doesn't inadvertently toggle these setting mid-code in
the original caller, AND that events aren't inadvertently left turned
off.

Just drop this into a standard module and reuse for all your
projects...

Sub EnableFastCode(Caller$, Optional SetFast As Boolean = True)
'The following will make sure only the Caller has control,
'and allows any Caller to take control when not in use.
If AppMode.CallerID < Caller Then _
If AppMode.CallerID < "" Then Exit Sub

With Application
If SetFast Then
AppMode.Display = .ScreenUpdating
.ScreenUpdating = False
AppMode.CalcMode = .Calculation
.Calculation = xlCalculationManual
AppMode.Events = .EnableEvents
.EnableEvents = False
AppMode.CallerID = Caller
Else
.ScreenUpdating = AppMode.Display
.Calculation = AppMode.CalcMode
.EnableEvents = AppMode.Events
AppMode.CallerID = ""
End If
End With
End Sub 'EnableFastCode

...which requires the following 'Type' declaration to work correctly.

Type udtAppModes
Events As Boolean
CalcMode As XlCalculation
Display As Boolean
CallerID As String
End Type
Public AppMode As udtAppModes

To use the procedure I just call it from any def and pass the args as
needed...

Sub MySub()
Const sSource$ = "MySub"
On Error GoTo errExit
EnableFastCode sSource '//turn it on
'...code follows

errExit:
EnableFastCode sSource, False ''//turn it off
End Sub 'MySub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default event that cannot be disabled?

On Monday, February 24, 2014 10:04:31 AM UTC-6, GS wrote:
In addition to Claus' good advice to impliment an error handler in your

complex routines, it sounds like you need a methodology in place to

properly manage Excel events!

I never even thought of doing it that way. I will copy and credit. Thank you.
(do you guys get paid by uS to help out?)

my old way:

Function disableEvents() As Boolean
disableEvents = Application.enableEvents
Application.enableEvents = False
End Function

Sub enableEvents(Optional previous_event_status As Boolean = True)
Application.enableEvents = previous_event_status
End Function


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default event that cannot be disabled?

(do you guys get paid by uS to help out?)

NO!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default event that cannot be disabled?

On Monday, February 24, 2014 10:50:04 AM UTC-6, GS wrote:
(do you guys get paid by uS to help out?)




NO!



--

Garry



Free usenet access at http://www.eternal-september.org

Classic VB Users Regroup!

comp.lang.basic.visual.misc

microsoft.public.vb.general.discussion


You should
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
apply cell change event to single column - WorksheetChange Event [email protected] Excel Programming 6 May 4th 08 02:28 AM
Click event on menu item is lost after first time firing of the event [email protected] Excel Programming 1 April 2nd 07 01:25 PM
Workbook_open event disabled by manual calc command Twotone Excel Programming 3 March 12th 07 07:46 PM
Event Procedure (re-activate automatic calulation if disabled) Edmund Excel Programming 1 June 30th 06 04:31 AM
worksheet change event error events disabled Peter[_21_] Excel Programming 2 July 10th 04 08:45 AM


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