ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable Macros in workbook programmatically (https://www.excelbanter.com/excel-programming/326670-disable-macros-workbook-programmatically.html)

quartz[_2_]

Disable Macros in workbook programmatically
 
Does anyone know how to programmatically disable macros as though the user
clicked the "Disable Macros" button on the security warning dialog?

If so, could you please post example code.

Thanks in advance.

Jim Thomlinson[_3_]

Disable Macros in workbook programmatically
 
You can not toggle the macro security settings programmatically in any way...
You however are the first person on the forum wanting to disable them... I
think you should get a gold star for that. This question comes up all the
time trying to enable macros.

You could however write some code that validates the user with some kind of
a login. Getting the password right would set a global boolean that is
checked immediately prior to any code executing. No password... No
execution...

HTH

"quartz" wrote:

Does anyone know how to programmatically disable macros as though the user
clicked the "Disable Macros" button on the security warning dialog?

If so, could you please post example code.

Thanks in advance.


quartz[_2_]

Disable Macros in workbook programmatically
 
Thanks again Jim.

Actually, my code is validating to a certain file location. I'm trapping if
the file has been moved because then other programs won't function correctly.
Have had a problem with people emailing the file itself rather than the link
to the file.

I guess I could have code to delete the code modules...but do you know
whether the "Trust access to visual basic project" check box setting goes
with the file or whether that is set on each user's machine?

"Jim Thomlinson" wrote:

You can not toggle the macro security settings programmatically in any way...
You however are the first person on the forum wanting to disable them... I
think you should get a gold star for that. This question comes up all the
time trying to enable macros.

You could however write some code that validates the user with some kind of
a login. Getting the password right would set a global boolean that is
checked immediately prior to any code executing. No password... No
execution...

HTH

"quartz" wrote:

Does anyone know how to programmatically disable macros as though the user
clicked the "Disable Macros" button on the security warning dialog?

If so, could you please post example code.

Thanks in advance.



All times are GMT +1. The time now is 06:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com