How to Fix Excel VBA Error 80070005 Access Is Denied
Question details
The user encounters run-time error -2147024891 (80070005) Access is denied while running an Excel VBA macro.

- 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 modifying your system security settings, save your current workbook progress and verify that you have administrative privileges on your Windows account.
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.
Copy your Excel workbook to a trusted local directory, such as your Desktop or the Documents folder, to rule out network permission issues.
Navigate to the folder your macro code is trying to access, right-click it, and select 'Properties' from the context menu.
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.
Open your workbook and execute the macro again to verify if the 'Access is denied' error has been resolved.

Review Antivirus and Endpoint Security Logs
Check if your security software is mistakenly flagging and blocking your VBA macro's behavior.
Isolate the Failing VBA Code
Use the VBA Editor's debugging tools to pinpoint the exact line of code causing the access denial.
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. Download the software: Visit the official WPS Office website and download the free installation package.
- 2. Install WPS Office: Run the installer and follow the quick on-screen instructions to set up the software on your computer.
- 3. Open your macro files: Launch WPS Spreadsheets and open your existing .xlsm files directly to continue your work without formatting loss.

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.




