1
votes

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

1
If the file is already opened, it will appear that it is not firing, because Excel will not open the same filename twice.jgallant
no file at all is open, I closed all workbooks (including the considered file) and just left excel runningThumper
What you're describing isn't normal Excel behavior. I suspect this is specific to the machine you are using for development. Does the same behavior occur on other machines as well?Jon Crowell
Jon is right. Even I am not able to reproduce the behavior. Can you upload a sample file say in www.wikisend.com and share the link here so that we can take a look? Do remember to remove any sensitive information before uploading.Siddharth Rout
Thanks for your feedback. I am doing some more tests at the moment. As the error occured at one of my users and I was able to reproduce it, I am quite certain it's not the machine. Nevertheless I am right now - like you - not able to reproduce using a new excel file...Thumper

1 Answers

2
votes

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