Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In the first part of my response, I was guessing that the workbook_open event
did indeed start--but it stopped before it did anything the user could notice. (I don't know what code the OP was using or how he knew that the event didn't fire.) Ian Robinson wrote: I've seen that proposed solution before but it misunderstands the nature of the problem - unless the proponents have a different problem, of course!. Since the Workbook_Open event does not fire (or appear to fire) in the first place, the procedure Sub workbook_Open() ... End Sub is never entered. In other words, it does not matter what code you put inside the Sub (eg merely MsgBox "Hello" or just Stop etc) it will not be run because VBA never gets a chance to. An alternative (and perhaps better) workwround to my previous workaround is to use code like this: Option Explicit Public iCalculationMode As Integer Private Sub Workbook_Activate() iCalculationMode = Application.Calculation Application.Calculation = xlCalculationAutomatic End Sub Private Sub Workbook_Deactivate() Application.Calculation = iCalculationMode End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Application.Calculation = xlCalculationManual Application.EnableEvents = False ThisWorkbook.Save Application.EnableEvents = True Application.Calculation = xlCalculationAutomatic ThisWorkbook.Saved = True End Sub This method avoids the need to set manual calculation via the menu bar and provides for other workbooks that might be open at the time. At one time I thought the problem was associated with UDFs that may exist and need calculation on startup but the pattern was never consistent. At other times, using Auto_Open worked, but not always (even that would not fire). If you trawl the MSDN Knowledge Base, it appears that Microsoft are aware that there is a problem but never offer a cause or solution other than suggesting that using Auto_Open *might* work. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Event doesn't fire | Excel Discussion (Misc queries) | |||
Workbook Open Event does not fire | Excel Programming | |||
Event class doesn't fire in embedded VBA | Excel Programming | |||
Date/Time Picker Event Won't Fire | Excel Programming | |||
Event to fire when pivottable is pivoted | Excel Programming |