Use VBA to open workbook without running macros?

markadon

Board Regular
Joined
Feb 12, 2007
Messages
193
Greetings,

I need to use VBA to open a workbook with macros disabled. How can I do this?

Thanks,
--Doug
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Don't have time to test this idea. But you might be able to shell out to the Excel.exe command and use the /s switch to open in safe mode... Just a thought.

Maybe you can sweet talk Smitty into trying!
 
Upvote 0
A friend found this solution:

Use Application.EnableEvents = False to disable the macros (and other events) then turn it back on when finished.

Works for me!
 
Upvote 0
That's not quite the same as what you asked for though. That opens the workbook without running any event code - any macros within the workbook are not disabled.
 
Upvote 0
Application.EnableEvents = False

I too thought of that (and I'm sure Smitty did too). But I didn't mention it because, as Rory said, it's not quite what the OP asked for. It is worth noting that turning off events, would indeed keep macros from executing upon the opening of the other workbook because workbooks opened programmatically do not execute the Auto_Open() method (see here for more info).
 
Upvote 0
I too thought of that (and I'm sure Smitty did too).

I had thought of that as well, but as Greg points out as it wasn't what was specifically asked for, I didn't mention it.

If you'd said "I have two workbooks, both with macros. I want #1 to open #2, but I don't want #2's code to run when it's opened by #1." I think we would have been on board right away. ;)
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,217
Members
448,554
Latest member
Gleisner2

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