Skip to content

Instantly share code, notes, and snippets.

@Mbosinwa
Forked from PSJoshi/block-macro-ms-office.txt
Last active February 19, 2025 11:03
Show Gist options
  • Save Mbosinwa/55aa6c050a57dd01296e85b91d3052c2 to your computer and use it in GitHub Desktop.
Save Mbosinwa/55aa6c050a57dd01296e85b91d3052c2 to your computer and use it in GitHub Desktop.
Block macros in Microsoft Office suite using registry
The default registry key for macro security is
[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Word\Security]
"VBAWarnings"=dword:00000001
You could set it with a script:
Set wso = CreateObject("WScript.Shell")
wso.RegWrite "HKCU\Software\Microsoft\Office\14.0\Word\Security\VBAWarnings", 1, "REG_DWORD"
and it would enable macros. This only works if Word is either closed when you run the script or restarted afterwards.
If you are in a company that uses GPOs to handle macro security it would probably be overwritten.
Block Macro in Microsoft office using Windows registry keys
============================================================
(ref - https://www.slipstick.com/outlook/block-macros-office-20132016/)
Office 2016
------------
HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\office\16.0\word\security
HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\office\16.0\excel\security
HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\office\16.0\powerpoint\security
In each key listed above, create this value:
DWORD: blockcontentexecutionfrominternet
Value = 1
Office 2013
-----------
HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\office\15.0\word\security
HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\office\15.0\excel\security
HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\office\15.0\powerpoint\security
In each key listed above, create this value:
DWORD: blockcontentexecutionfrominternet
Value = 1
Office 2010
-------------
HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\msproject\security
In each key listed above, create this value:
DWORD: VBAWarnings
Value = 2
Value 1: Enable All macros
Value 2: Disable all macros with notification
Value 3: Disable all macros except those digitally signed
Value 4: Disable all without notification
* How to get MS Office version information?
Make use of windows management for instrumentation query.
c:\Users\joshi> wmic product where "Name like '%Office%'" get name,version
Another way using powershell is explained here - https://www.drivereasy.com/knowledge/generate-list-installed-programs-windows/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment