VBA & Macro Problems

How to Fix Excel VBA Error 80070005 Access Is Denied

Huma Ashraf ChHuma Ashraf Ch Oct 15, 2026 869 views

Question details

The user encounters run-time error -2147024891 (80070005) Access is denied while running an Excel VBA macro.

How to Fix Excel VBA Error 80070005 Access Is Denied
Product
Microsoft Excel
Device & OS
Windows
Scenario
Running a VBA macro that attempts to read, write, or modify external folders, network drives, or registry keys.
Observed behavior
The macro execution halts, and Excel displays an 'Access is denied' error message because the operating system or security software blocks the action.
Before you start

Before modifying your system security settings, save your current workbook progress and verify that you have administrative privileges on your Windows account.

Solution 1Recommended

Check and Modify File and Folder Permissions

Ensure the folder or network drive your macro is trying to access allows read and write permissions for your current user account.

VBA error 80070005 is essentially a Windows permission error. If your macro tries to save a file to a folder that is restricted (like the root C: drive or a read-only network share), Windows will block the action.

1
Move to a trusted location

Copy your Excel workbook to a trusted local directory, such as your Desktop or the Documents folder, to rule out network permission issues.

2
Open folder properties

Navigate to the folder your macro code is trying to access, right-click it, and select 'Properties' from the context menu.

3
Adjust security settings

Go to the 'Security' tab, select your user account from the list, and verify that the 'Modify' and 'Write' checkboxes are allowed under the Permissions section. Click 'Edit' to change them if necessary.

4
Rerun the macro

Open your workbook and execute the macro again to verify if the 'Access is denied' error has been resolved.

Check and Modify File and Folder Permissions
Administrative Rights: If you are on a corporate network, you may need to contact your IT administrator to grant you the necessary folder permissions.
Free Microsoft Office alternative

Try WPS Office for a Seamless and Secure Spreadsheet Experience

If strict Microsoft Office security policies or persistent VBA run-time errors are slowing you down, consider switching to WPS Office. It provides a lightweight, highly compatible alternative that supports essential spreadsheet functions and macros with a familiar user interface.

  1. 1. Download the software: Visit the official WPS Office website and download the free installation package.
  2. 2. Install WPS Office: Run the installer and follow the quick on-screen instructions to set up the software on your computer.
  3. 3. Open your macro files: Launch WPS Spreadsheets and open your existing .xlsm files directly to continue your work without formatting loss.
Fully compatible with Microsoft Excel formats (.xlsx, .xls, .csv, .xlsm).Free to download and use with a highly familiar user interface.Lightweight installation that runs smoothly on most operating systems.Seamless migration process without steep learning curves.
microsoft office alternative - wps office

Frequently Asked Questions

Why am I getting the VBA run-time error 80070005?

This error code is a standard Windows 'Access Denied' message. It triggers when your VBA macro attempts to read, write, or execute a file, folder, or registry key that your current Windows user account or security software does not have permission to access.

Will reinstalling Microsoft Office fix the Access is Denied VBA error?

Generally, no. Reinstalling Microsoft Office does not reset Windows folder permissions or security policies, which are the root causes of this error. You must address the underlying operating system or antivirus restrictions instead.

How do I stop Windows Defender from blocking my Excel macro?

Go to Settings > Privacy & security > Windows Security > Virus & threat protection. Under Ransomware protection, click 'Manage ransomware protection'. If 'Controlled folder access' is enabled, click 'Allow an app through Controlled folder access' and add Excel.exe to the allowed list.