Yes, you can fix VBA runtime error 335 ("Could not access system registry") quickly. This error occurs when your Excel VBA macro tries to read or write to the Windows Registry but lacks proper permissions, permissions are disabled, or the registry key is missing. The fix usually involves adjusting permissions, repairing the registry, or updating your system settings. Start by checking if Excel is running as administrator—if not, run it elevated to access all registry keys. If that doesn’t work, try temporarily disabling antivirus software, as some security tools block registry access, or repair Windows Registry Editor permissions via Group Policy or System Properties.

What You'll Need

  • A working copy of Microsoft Excel with VBA enabled
  • Administrator privileges on your Windows PC
  • Access to Registry Editor (if needed for manual fixes)
  • A temporary workaround (like disabling antivirus) if permissions are blocked

Step-by-Step

  1. Run Excel as Administrator
    1. Press Win + X and select Run as administrator. If prompted, confirm with your password.
    2. Restart Excel in this elevated mode to grant full registry access.
    3. Try your problematic VBA macro again. Most registry-related errors resolve immediately.
    If this doesn’t work: Move to the next step.
  2. Disable Antivirus Temporarily
    1. Close all running programs, including Excel.
    2. Open your antivirus software (e.g., Norton, McAfee, Windows Defender).
    3. Pause or disable real-time protection for the duration of your VBA testing.
    4. Reopen Excel in administrator mode and test your macro.
    5. Re-enable antivirus protection afterward.

    Antivirus tools sometimes flag legitimate registry operations as threats, blocking VBA from accessing them.

  3. Reconfigure Registry Permissions (Manual Fix)
    1. Press Win + R, type regedit, and hit Enter. (This opens the Registry Editor—back up the registry first if unsure, though errors rarely cause data loss.)
    2. In Registry Editor, navigate to the registry key used by your VBA macro. Common examples include:
      • HKEY_CURRENT_USER\Software
      • HKEY_LOCAL_MACHINE\SOFTWARE
      • Any custom keys added by your Excel add-ins.
    3. Right-click the key > Permissions. Ensure your user account (e.g., YourUsername) has Full Control.
    4. If permissions are missing or misconfigured, click Edit > Select Permissions, then apply Full Control to your user account.
    5. Restart Excel and test again.

    This step is for advanced users; if unsure, skip to automatic fixes below.

  4. Repair Windows Registry Editor Permissions via Group Policy
    1. Press Win + R, type gpedit.msc, and hit Enter. (This opens Local Group Policy Editor—only available on Windows Pro/Enterprise; Professional editions may lack this tool.)
    2. Navigate to: Computer Configuration > Administrative Templates > Windows Components > Windows Registry
    3. Double-click the option labeled Registry Editor, then set it to Enabled. Click Apply > OK.
    4. Restart your PC and test Excel again. Registry Editor permissions should now grant VBA full access.

    If Group Policy Editor isn’t available, proceed to the next step.

  5. Reset Registry Permissions Using System Properties
    1. Open the Registry Editor again (as in Step 3).
    2. Back up your registry by exporting a backup (File > Export).
    3. Navigate to the registry key path used by your VBA code (e.g., HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\Options).
    4. Right-click the key > Delete. Confirm deletion.
    5. Restart Excel and let Windows recreate permissions. The registry key will now inherit default permissions from the system.

    Warning: Deleting a registry key permanently removes its settings. Only do this if you’re sure the key isn’t critical to other applications.

  6. Update or Reinstall Excel
    1. Open Control Panel > Programs > Programs and Features.
    2. Find Microsoft Excel, right-click > Uninstall.
    3. Follow Microsoft’s reinstallation instructions. Ensure you download the latest version from the Microsoft Store.
    4. After reinstalling, re-enable your macros (File > Options > Trust Center > Trust Center Settings > Macro Settings).

    Outdated Excel versions may have registry access bugs. Updating fixes compatibility issues.

Common Mistakes

  • Ignoring Administrator Rights: Running Excel without admin privileges locks out registry access. Always run Excel as administrator to test fixes.
  • Skipping Antivirus Checks: Some security tools misidentify VBA registry calls as malware. Temporarily disabling them often resolves the error.
  • Deleting Critical Registry Keys: Deleting keys like HKEY_CURRENT_USER\Software can break other applications. Always back up the registry before manual edits.
  • Assuming Registry Keys Exist: VBA errors sometimes occur when the registry key isn’t properly initialized. Verify the key’s existence before editing permissions.

Tips

  • Test in Safe Mode: If the error persists, run Excel in Safe Mode (right-click Excel > Open with Safe Mode) to rule out third-party add-ins interfering with registry access.
  • Use a Registry Cleaner (Carefully): Tools like Registry Mechanic can repair corruption, but they may introduce new issues. Prefer manual fixes when possible.
  • Check for 64-bit vs. 32-bit Conflicts: If you’re using a 64-bit version of Windows but a 32-bit version of Excel, the registry paths may differ. Enable 64-bit Excel (File > Options > Trust Center > General) to match your system.
  • Log Macro Errors: Enable logging in VBA by adding this line at the start of your macro:
    Application.OnTime Now, "LogError", True
    Then create a new module to handle errors. This helps pinpoint which registry call is failing.

Troubleshooting

If none of the above steps resolve the error, try these advanced measures:

  1. Run a System File Checker Scan
    1. Open Command Prompt as Administrator.
    2. Type: sfc /scannow and press Enter.
    3. Windows will scan and repair corrupted system files. Close Excel during this process.
  2. Fix Windows Registry Permissions via Command Line
    1. Open Command Prompt as Administrator.
    2. Run: icacls "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Office16" (replace "Office16" with your Excel version if different).
    3. This adjusts permissions for Excel shortcuts. Test Excel afterward.
  3. Create a New User Account
    1. Go to Control Panel > User Accounts > Family Safety > Manage another account.
    2. Create a new user account. Log in as this user and test Excel. If the error disappears, registry permissions were likely the issue.
  4. Replace the VBA Project
    1. Close all Excel instances.
    2. Go to the folder where Excel stores VBA projects (e.g., C:\Users\[YourUsername]\AppData\Roaming\Microsoft\Excel\XLSTART).
    3. Delete or rename the XLSTART folder. This removes problematic macros that might interfere with registry access.

Frequently Asked Questions

Why does my VBA macro keep failing with "could not access system registry" when it worked before?

The error likely stems from registry permission changes (e.g., Windows updates, antivirus updates, or user account changes). Running Excel as administrator or repairing registry permissions usually fixes it.

Can I still use VBA if I don’t have admin rights?

No, VBA requires admin privileges to access most registry keys. You could create a macro that writes to a text file instead, but registry access is essential for many Excel automation tasks.

Will repairing registry permissions break other Excel features?

Unlikely if you follow the steps carefully. However, deleting registry keys (Step 5) can break add-ins or settings. Always back up the registry before manual edits.

Does this error happen only in Excel, or in other Office apps too?

It’s most common in Excel, but similar errors can occur in Word or PowerPoint if they use registry settings for fonts, themes, or customization. The fixes are the same.

How do I know which registry key my VBA code is trying to access?

Debug your code by adding a line like:

Debug.Print GetObjectPath("HKEY_CURRENT_USER\Software")
This logs the key path used, which you can then check in Registry Editor.

What if my antivirus is from a reputable brand, and disabling it causes issues?

Instead of disabling, configure your antivirus to allow registry access for Excel:

  1. Open your antivirus dashboard.
  2. Find the exclusion settings (e.g., "Add to Exclusion List").
  3. Add the path to Excel’s VBA projects (e.g., C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE).
This prevents false positives without disabling the tool entirely.