Workbook_Open when ActiveX not yet enabled

MichaelSchulz

Board Regular
Joined
Apr 10, 2014
Messages
64
I have a workbook with ActiveX controls that works fine. There is a Workbook_Open code in ThisWorkbook.

The problem is when another user opens the workbook for the first time. The user receives the security message for enabling ActiveX controls but, at the same time, the Workbook_Open routine is attempting to run.

The result is a run-time error.

Once the ActiveX enabled, the workbook opens without a problem and the Workbook_Open code fires off as intended.

Is there a way to keep the routine from running until after the user enables ActiveX?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Have you considered using an error handler in the workbook open event ?

Something like this :

Private Sub Workbook_Open()
On error Resume Next

If err.number = (Look up the error number you are getting) Then Exit Sub

.... Rest of the code goes here ....

End Sub
 
Upvote 0
Have you considered using an error handler in the workbook open event ?

Something like this :

Private Sub Workbook_Open()
On error Resume Next

If err.number = (Look up the error number you are getting) Then Exit Sub

.... Rest of the code goes here ....

End Sub

That would solve part of the problem as it stands now. A first-time user could then enable ActiveX but the bit of code in Workbook_Open still would not have ran.

To phrase the issue in another way:
How can I have a subroutine run after the user has opened the workbook—and after a first-time user has enabled ActiveX—but before the user does anything else?
 
Upvote 0

Forum statistics

Threads
1,215,566
Messages
6,125,597
Members
449,238
Latest member
wcbyers

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top