Workbook_Open sub won't run when I open the workbook?
Make sure your Private Sub Workbook_Open() subroutine is pasted inside of the This Workbook object and not in a Module, Form, or Sheet object.
Interesting. In 2009 a conflict with conditional formatting of the sheet to open is described, as in vbforum post.
It seems that this bug still exists in excel and prevents the workbook_open
event from being fired.
I have a workbook (old XLS-binary format) that simply does not fire the event in Excel 2003 and 2007 but does in 2013. I deleted all conditional formatting from the first worksheet but could still not get the workbook_open
procedure to run in elder Excel-Versions.
A Workaround, I use in distributed workbooks is to use a local variable and a second event in the workbook as follows:
''
' private variable
Private wbOpenEventRun as Boolean
''
' procedure to be called by excel when workbook opens
Private Sub Workbook_Open()
wbOpenEventRun = true
' perform tasks
End Sub
''
' the selection change event fires usually.
' performance is not reduced
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Not wbOpenEventRun Then Workbook_Open
' perform tasks in reaction of selection change events, if required
End Sub
The solution I found was running the below code and then the "Open" event worked.
Sub EventRestore()
Application.EnableEvents = True
End Sub