Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Auto_Open and Workbook_Open

I ran into trouble with Auto_Open and Workbook_Open
Workbook_Open, the officially recommended method
for executing macros automatically when
opening a workbook, does not work when
Application.EnableEvents = False

Auto_Open, on the other hand, always seems to be run.
I have some (protected) addins (not written by me) which rely on
workbook_open to be executed.
It seems that one of these addins is setting
Application.EnableEvents = False
Anyhow, when ich check EnableAddins after starting Excel, it is false.

So I tested if for one workbook Auto_Open is executed
before Workbook_Open. Then, Auto_Open could set
Application.EnableEvents = True
and then WorkBook_Open would be executed.
This does not work. It seems that if at all
Workbook_Open is executed before Auto_Open.

Is there a way to ensure execution of Workbook_Open
in a Workbook where one can not change the code?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Auto_Open and Workbook_Open

How about something like:

Option Explicit
Sub testme()

Dim wkbk As Workbook

'turn off events to match problem
Application.EnableEvents = False
Set wkbk = Workbooks.Open _
(Filename:="C:\my documents\excel\this is my book.xls")
Application.EnableEvents = True

Application.Run "'" & wkbk.Name & "'!thisworkbook.workbook_open"

End Sub

I put this in that other workbook
Option Explicit
Private Sub Workbook_Open()
MsgBox "Hi from:" & Me.FullName
End Sub

and I got a message back.

Erich Neuwirth wrote:

I ran into trouble with Auto_Open and Workbook_Open
Workbook_Open, the officially recommended method
for executing macros automatically when
opening a workbook, does not work when
Application.EnableEvents = False

Auto_Open, on the other hand, always seems to be run.
I have some (protected) addins (not written by me) which rely on
workbook_open to be executed.
It seems that one of these addins is setting
Application.EnableEvents = False
Anyhow, when ich check EnableAddins after starting Excel, it is false.

So I tested if for one workbook Auto_Open is executed
before Workbook_Open. Then, Auto_Open could set
Application.EnableEvents = True
and then WorkBook_Open would be executed.
This does not work. It seems that if at all
Workbook_Open is executed before Auto_Open.

Is there a way to ensure execution of Workbook_Open
in a Workbook where one can not change the code?


--

Dave Peterson

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_Open () Bill Martin Excel Discussion (Misc queries) 12 December 20th 05 05:37 PM
Auto_Open and Workbook_Open in Addins Erich Neuwirth Excel Programming 1 July 11th 04 06:54 PM
Workbook_Open Eric Marple Excel Programming 3 May 10th 04 01:24 AM
Help with Workbook_Open Ruan[_3_] Excel Programming 7 April 28th 04 07:52 AM
Auto_Open Vs Workbook_open Soniya Excel Programming 2 September 23rd 03 03:56 PM


All times are GMT +1. The time now is 08:04 PM.

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"