How to Fix Excel Run-Time Error 5 on Windows Computers
Question details
A user encounters Run-Time Error 5 when opening an XLSM macro file on a different computer, despite the file working correctly on the original machine.

- Product
- Microsoft Excel
- Device & OS
- Windows
- Scenario
- Sharing and executing VBA macros (.xlsm) across multiple computers with potentially different system setups.
- Observed behavior
- The macro triggers a Run-Time Error 5 on a specific user's computer, likely due to VBA code compatibility, missing references, or 32-bit versus 64-bit architectural differences.
Before making changes, verify that macros are fully enabled in the Trust Center settings on the affected computer, and ensure the user has the necessary permissions to access any network folders referenced in the VBA code.
Isolate the XLSM File and Verify Excel Architecture
Determine if the issue is specific to the workbook itself or caused by differences between 32-bit and 64-bit Excel installations.
Run-Time Error 5 (Invalid Procedure Call or Argument) frequently occurs when a macro written on a 32-bit version of Excel is executed on a 64-bit version without proper API declarations, or when a file becomes corrupted during transfer.
Send a different, known-working XLSM file to the affected user. Have them open it and run a basic macro to see if the issue is isolated to a specific workbook.
On both the working and non-working computers, open Excel, click on 'File' in the top ribbon, and select 'Account' from the left-hand menu.
Click the 'About Excel' button. Note the exact build number and check whether the installation is 32-bit or 64-bit (listed at the end of the first line in the dialog box).
If the original PC is 32-bit and the affected PC is 64-bit, open the VBA Editor (Alt + F11) and update any Windows API 'Declare' statements by adding the 'PtrSafe' keyword.

Debug the VBA Code for Missing References
Use the built-in VBA debugger to locate the exact line of code causing the error and check for missing libraries or invalid paths.
Try WPS Office for Seamless Spreadsheet Compatibility
If you frequently encounter version conflicts and architecture errors in Microsoft Excel, consider switching to WPS Office. It provides a highly compatible environment for your spreadsheets with a familiar interface, reducing the hassle of cross-device file sharing.
- 1. Download the Installer: Visit the official WPS website and click the download button to get the latest WPS Office installation package.
- 2. Install WPS Office: Run the downloaded executable file and follow the simple on-screen instructions to install the suite on your computer.
- 3. Open Your Spreadsheets: Launch WPS Spreadsheet and directly open your existing Excel files to enjoy seamless editing and formatting compatibility.

Frequently Asked Questions
What does Run-Time Error 5 mean in Excel VBA?
Run-Time Error 5 indicates an 'Invalid Procedure Call or Argument'. This usually happens when a macro passes an unacceptable value to a function, attempts to call a function that is not supported by the current Excel environment, or tries to access a file path that does not exist on the computer.
Why do macros work on a 32-bit Excel but fail on a 64-bit Excel?
64-bit versions of Excel require VBA code that calls Windows API functions to be explicitly updated for 64-bit environments. You must modify the code to include the 'PtrSafe' keyword in Declare statements and use the 'LongPtr' data type for pointers and handles to avoid memory access errors.
How do I check if my Excel is 32-bit or 64-bit?
Open Microsoft Excel, click on the 'File' tab, then select 'Account' at the bottom of the left sidebar. Click the 'About Excel' button. A dialog box will appear displaying the version number, and it will clearly indicate whether it is 32-bit or 64-bit at the end of the very first line of text.




