Thumper
Thumper

Reputation: 131

Workbook_Open() is not executed with excel already running

using excel 2007 I programmed a macro, which I would like to start with the Workbook_Open() call (placed in "thisWorkbook").

This works fine as long as this is a new "excel-session", therefore it is started together with the xlsm-file / I start excel and load the file.

However as soon as excel is already running, the Workbook_Open() function is not executed. The macro otherwise still works fine, as soon as I start it manually after the workbook has been loaded.

To clarify: This happens even if no other workbook is open, just excel, so I am convinced that no other calculation could interfere with the Workbook_Open() call (as proposed most of the time).

(the problem seems to exist for excel 2003 too: Excel Workbook Open Event macro doesn't always run)

I would be grateful for any hints how to call my macro in any case! (As my users most of the time already have excel up and running when starting my file) Thanks

Upvotes: 1

Views: 5483

Answers (1)

Bruno Leite
Bruno Leite

Reputation: 1477

You can create a global bool variable, and set a value with true in workbook_open .

And after you verify value of variable

'In Module
Global BoolCheck As Boolean


Sub CheckValue()
'Verify if Workbook_Open Event is called
If BoolCheck = False Then
    'case not call the
    ActiveWorkbook.Workbook_Open
End If
End Sub

'in Workbook Object
Public Sub Workbook_Open()
    BoolCheck = True
End Sub

[]´s

Upvotes: 2

Related Questions