LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Workbook Open event does not fire

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
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
Event doesn't fire Frank Xia Excel Discussion (Misc queries) 6 February 11th 06 12:54 AM
Workbook Open Event does not fire Jon Somerset Excel Programming 1 October 15th 04 12:49 PM
Event class doesn't fire in embedded VBA Tornados[_5_] Excel Programming 0 September 28th 04 03:27 PM
Date/Time Picker Event Won't Fire Mark Driscol Excel Programming 1 July 14th 04 03:28 PM
Event to fire when pivottable is pivoted Tod Excel Programming 1 April 5th 04 09:09 PM


All times are GMT +1. The time now is 08:31 AM.

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"