I have inserted an ActiveX spreadsheet control into an Excel VBA form.
I have written a procedure in the ThisWorkbook.Workbook_Open() event and it will not execute upon opening the workbook when the ActiveX spreadsheet control exists on the form.
In effort to simplify the problem, I have:
- Created a new workbook.
- Added a blank form "UserForm1".
- Added an ActiveX spreadsheet control to "UserForm1", "Spreadsheet1".
- In ThisWorkbook, added the Private Workbook_Open() event: The Workbook_Open event does not execute when the workbook is opened. When the spreadsheet control is deleted from the form, the workbook_open event executes normally.
Macros are enabled in both cases. Other macros execute successfully when manually called.
How do I get the workbook_open event to execute with an ActiveX control on a VBA form?
Private Sub Workbook_Open()
MsgBox "Workbook_Open event has executed."
End Sub
UPDATE: When security is set to "Disable all macros with notification" and file is opened for the first time in protected view, the Workbook_Open() event is fired. On subsequent opening of the file, the event is not fired.