ActiveX spreadsheet control disables workbook_open event - vba

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.

Related

VBA : Detect a change of Activeworkbook

I have a XLA AddIn macro with a main menu Userform. I need to enable/disable boutons on this menu userform according to the Activeworkbook.
My problem is that I don't know how to update the Userform when the user change or close the Activeworkbook.
I do have a UserForm_Activate, which update the Userform. But that event is not triggered when the user close the Activeworkbook then click on the Userform.
I would need to update the Userform either :
as soon as the Activeworkbook is changed or closed
or as soon as the user reach the Userform (ie. before he can click on any control).
How would you proceed ?
In the ThisWorkbook module of your xla:
Private WithEvents xlApp as Excel.Application
You will then see that xlApp has events such as WorkbookActivate and WorkbookDeactivate etc.

Macro not launching on workbook open

I have a workbook that I've been using an sub auto_open macro on and it's been fine.
However I am now trying to open it from another workbook and the auto_open macro doesn't work. It just opens and no macros run.
If I add a Workbook_open in "This workbook" to run the same macros it works fine. However if I run the workbook normally (outside of the link) it now opens and doesn't run any macros.
Weirdest thing is if I allow both auto_open and workbook_open it runs twice which is not what I want obviously.
Private Sub Workbook_Open()
StartMacro
End Sub
Public Sub Auto_Open()
StartMacro
End Sub
My ideal would be to have either as long as it will open when launched normally or via a link in a workbook.
Any ideas why I'm getting these issues?
auto_open subs needs to be in a module, not in an Excel object (like a sheet's code, nor ThisWorkbook). Here is further reference about auto-startup options in Excel.

How to goto excel vba code when opening the macro opens Userform instead of Thisworkbook?

I have written excel VBA code containing Userform and added code to show userform and hide Thisworkbook when the macro is opened. It shows userform during Start up. How to see the vba code, when userform is opened? Clicking Alt+F11 on Userform is not taking to VBA editor.
Press the Shift key and hold it down while you open the file. This will prevent the macro from firing (I'm assuming you have Workbook_open setting both Application.Visible = False and your userform's .Show method?)

Fire macro in Personal.xlsb on ANY workbook open

I am attempting to place a macro in Personal.xlsb that will fire whenever any workbook is opened. I have searched multple sites for an answer and all relate to Auto_Open or WorkBook_Open which have to be in a macro running in the workbook being opened. Is there a way to see these events from another workbook?

VBA add-in: How to run code on "enabled"

I am writing an add-in for Excel 2003, using VBA.
I have an Auto_Open subroutine, which automatically runs some code (setting up menus, etc) whenever the add-in is Opened as a file.
What subroutine name (or other logic) do I need to use in order to have code that automatically runs when the add-in is "Enabled" through Excel's Add-in manager? (And, relatedly, when it is Disabled)
Auto_Open and Auto_Close will do what you want. Checking the addin in the Addins dialog opens it, and unchecking it closes it.
Check out the Workbook_AddinInstall Event.
From Excel's VB Help, this event:
Occurs when the workbook is installed as an add-in
Ex:
Private Sub Workbook_AddinInstall()
MsgBox "This workbook was installed as an addin."
End Sub
The Workbook_AddinUninstall Event fires when the workbook is uninstalled.