Blocking VBA from running

Martin1962

New Member
Joined
Mar 17, 2014
Messages
10
Hi,

I have the following issue :

I'm opening an xlsm file called Generator.xlsm, presenting a GUI (Userform) to the user.
At the end, I need to open a second xlsm file called Package.xlsm (basically a template, with some tabs that already contain basis data), and lots of VBA code.
Generator.xlsm writes missing data in Package.xslm and saves it.

Can I block the VBA code in Package.xlsm from running when opened (in background) by Generator.xlsm ?
The idea is to run the VBA code in Package.xlsm only when it's opened with all required data available.

Can I solve this by doing this :

In Package.xlsm (in Workbook_open), check for the presense of a specific tab.
If missing, skip rest of the VBA code.

Thanks for any advise/suggestions.

Martin
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Loop over all sheets, get the name property of each, test if any name matches and if the sheet name doesn't exist, use Exit Sub after the loop.
 
Upvote 0
Can I block the VBA code in Package.xlsm from running when opened (in background) by Generator.xlsm ?

Yes. Assuming that the code is event code, you can simply disable events using application.enableevets = false before opening the workbook, then re-enable them again afterwards.
 
Upvote 0

Forum statistics

Threads
1,215,641
Messages
6,125,986
Members
449,276
Latest member
surendra75

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