Open A Workbook With Macros Disabled

animas

Active Member
Joined
Sep 28, 2009
Messages
396
How to disable macros for a particular workbook using VBA code (even if user clicks enable macros during open)?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
It seems to me your best option is to protect the code Tools > VBA Project Properties > Protection and then make all Sub's private.

This way if the user selects Alt + F8 there are no macros available to run and if they select Alt + F11 the VBAProject is password protected.
 
Upvote 0
I meant disable all vba code all together so that no vba will run even if macro is enabled.

I was trying something like
Code:
Public Sub DisableAllMacros()
    If Range("_DisableAllMacros") = "YES" Then
        Exit Sub
    End If
End Sub
Here user can select if vba should be in use, by changing value of named range _DisableAllMacros from a worksheet.

DisableAllMacros() sub can be called at starting of each vba sub or function.

Is there any more efficient way to do this task?
 
Upvote 0
Not really sure on this one. Maybe somebody else will have a solultion.

One thing that could help is conditional compilation.

I don't quite understand it myself, but one thing it can be used for is switching back and forth between test and production.

Again, sorry I can't help more but surely somebody else has a great idea
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,823
Members
452,946
Latest member
JoseDavid

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