Vba Programmatic Access Is Not Trusted

When working with VBA (Visual Basic for Applications) in Microsoft Excel, Word, or Access, you may encounter the error ‘Programmatic Access Is Not Trusted.’ This issue typically occurs when your macro or script tries to access external applications or manipulate Outlook, Word, or other Office applications.

This security restriction is designed to prevent unauthorized scripts from executing harmful operations. However, if you are developing trusted macros for personal or business use, you may need to enable programmatic access manually.

In this guide, we will explain:

  • What the ‘Programmatic Access Is Not Trusted’ error means
  • Why Microsoft Office restricts programmatic access
  • How to enable VBA programmatic access in Excel and other Office applications
  • Security considerations when enabling this feature

1. Understanding the Error ‘VBA Programmatic Access Is Not Trusted’

What Does This Error Mean?

This error occurs when a VBA macro tries to control another Microsoft Office application or interact with the system. Microsoft Office blocks this action by default to protect users from malicious scripts.

Common Scenarios Where This Error Occurs

  • Your macro is trying to send emails via Outlook using VBA.
  • You are using VBA to manipulate Word or PowerPoint from Excel.
  • Your script accesses the Windows file system.
  • You are trying to use late binding (CreateObject or GetObject) to open an Office application.

Error Message Example

When running your macro, you might see an error similar to:

Run-time error '70': Permission denied.

or

Automation error. Programmatic Access to Visual Basic Project is not trusted.

By default, programmatic access to VBA is disabled for security reasons. You need to enable it manually if you trust the macro.

2. Why Microsoft Office Blocks Programmatic Access by Default

Microsoft Office includes built-in security features to protect users from malicious macros and automation scripts.

Security Risks of Enabling VBA Programmatic Access

  • Malware Risk – Hackers can exploit VBA macros to execute harmful scripts without user consent.
  • Phishing Attacks – Malicious macros can send emails via Outlook or extract user data.
  • Unauthorized Automation – If left unprotected, attackers could use VBA to manipulate files, databases, or system settings.

Because of these risks, Office blocks external programmatic access unless you explicitly allow it.

3. How to Enable VBA Programmatic Access in Office Applications

If you trust your VBA macros, you can manually enable programmatic access in Office settings.

Method 1: Enabling Programmatic Access in Trust Center (Recommended)

  1. Open Excel (or any Office application).
  2. Click on FileOptions.
  3. Select Trust Center on the left panel.
  4. Click Trust Center Settings.
  5. Navigate to Macro Settings.
  6. Check the box ‘Trust access to the VBA project object model.’
  7. Click OK and restart Excel.

Method 2: Enabling Programmatic Access via Windows Registry

If the Trust Center option is disabled, you can modify the Windows Registry to enable programmatic access manually.

Steps to Modify the Registry

Warning: Modifying the Windows Registry can cause system issues if done incorrectly. Proceed with caution.

  1. Press Win + R, type regedit, and hit Enter.
  2. Navigate to the following path:
    HKEY_LOCAL_MACHINESOFTWAREMicrosoftOffice16.0ExcelSecurity

    (Change 16.0 to the correct version for your Office installation:

    • Office 2016/2019/365 → 16.0
    • Office 2013 → 15.0
    • Office 2010 → 14.0)
  3. Look for a DWORD value named AccessVBOM.
  4. If it does not exist, right-click → New → DWORD (32-bit) Value and name it AccessVBOM.
  5. Set its value to 1 (Enable).
  6. Restart Excel.

This change bypasses the Trust Center setting and allows programmatic access permanently.

4. Alternative Workarounds for VBA Programmatic Access Issues

If you don’t want to modify Trust Center settings or Registry, you can try these workarounds:

Option 1: Run Excel as Administrator

  1. Close Excel completely.
  2. Right-click on the Excel shortcut.
  3. Click Run as administrator.
  4. Open your VBA macro and test if the issue is resolved.

This method temporarily grants programmatic access but does not permanently enable it.

Option 2: Digitally Sign Your Macro

  1. Open Excel and go to DeveloperVisual Basic.
  2. Click ToolsDigital Signature.
  3. Select a trusted certificate (or create one using SelfCert.exe).
  4. Save and restart Excel.

Signed macros are trusted by Office, which can reduce security restrictions.

5. Fixing ‘Programmatic Access Is Not Trusted’ for Outlook Macros

If you are automating Outlook emails via VBA, you may also need to enable a separate setting in Outlook Trust Center:

Steps to Allow Outlook Programmatic Access

  1. Open Outlook.
  2. Click FileOptions.
  3. Go to Trust CenterTrust Center Settings.
  4. Click Programmatic Access.
  5. Select ‘Never warn me about suspicious activity’.
  6. Click OK and restart Outlook.

Now, your VBA scripts can send emails and manipulate Outlook without restrictions.

6. Best Practices for Secure VBA Automation

Even if you enable programmatic access, it is important to maintain security in VBA macros:

Enable Macros Only for Trusted Documents – Don’t allow macros in untrusted files.
Use Digital Signatures – Sign your VBA projects with a certificate.
Restrict Macro Execution in Group Policies – If using Office in an organization, set strict IT policies.
Monitor Registry Changes – Ensure that malicious programs do not alter security settings.

By following these practices, you can safely use VBA automation without compromising security.

The ‘Programmatic Access Is Not Trusted’ error in VBA occurs due to Microsoft Office security restrictions. While these measures help prevent malware attacks, they can also block legitimate macros.

Summary of Fixes:

Enable ‘Trust access to the VBA project object model’ in Trust Center.
Modify Windows Registry (AccessVBOM = 1) if Trust Center is locked.
Run Excel as Administrator to bypass security temporarily.
Sign your VBA macros with a digital certificate to avoid security warnings.
Adjust Outlook settings if automating emails via VBA.

By applying these methods, you can enable programmatic access in VBA safely and continue using macros efficiently.