Summary: In this blog, we will discuss about ‘Cannot open or run macro, because it is not valid’ error that prevents users from using macros in MS Access. This blog will help you troubleshoot the issue by using some simple workarounds. If the macro error occurs due to corruption in the Access database, consider using an Access repair tool to repair the database and recover the macro(s).
You may receive the error ‘Cannot open or run macro, because it is not valid’ with an error code 32002. It is a runtime error that usually occurs when logging in to MS Access or when Access crashes while running.
What Causes ‘Cannot open or run macro, because it is not valid’ Error?
There is no evident reason as to what causes the error. But, based on the user’s experience, the error may occur due to one of the following reasons:
- Microsoft Access application crashes when editing, saving or closing a macro.
- There is a problem with Access macros or the VBA macro code.
- Access database containing macros is corrupted or damaged.
Workarounds to Fix ‘Cannot open or run macro, because it is not valid’ Error
Following are some workarounds you can use to troubleshoot the MS Access 32002 runtime error. If a workaround does not work for you, try the following one.
Workaround 1 – Use Single Step Mode to Test the Macro
Microsoft recommends testing a macro by using a single step mode. Using this mode, you can observe macro execution and results of each macro action. Also, it helps identify any action that leads to an error or any unwanted outcome.
Here’s how you can use the single step mode:
- In MS Access, right-click the macro from the ‘Navigation Pane, and select ‘Design View’.
- Click the’ Design’ tab in the ‘Tools’ group, then click ‘Single Step’.
- Press the Run button. If the macro you want to test is new or edited, follow the prompts to save the macro before running it.
- A Macro Single Step dialog box will open containing details about the macro and the macro action. Also, it provides information about the error number. If the ‘Error Number’ box has zero, it means no error has occurred.
- Take any of these steps:
- Click ‘Step’ to perform the action displayed in the Macro Single Step dialog box.
- Click ‘Stop All Macros’ to stop the macro and exit the dialog box.
- Click ‘Continue’ to switch single stepping off and run the rest of the macro.
Workaround 2 – Run MS Access Database without VBA code
Note: This workaround only works for ACCDB files; it won’t work for ACCDE files.
Press and hold down the ‘shift’ key when opening an Access database to bypass the code. If the database opens without the 32002 error, then there is a problem with your code. You need to fix the code to resolve the issue.
Workaround 3 – Turn on Trusted Access to Macros
- In your MS Access program, open a blank database.
- From the blank database screen, click File > Options.
- Select the ‘ Trust Center ‘ tab from the ‘Access Options’ dialog box.
- Click the ‘Trust Center Settings’ button.
- Select the “Enable all macros” option from the dialog box that opens, then click ‘OK’ to apply the changes.
Workaround 4 – Update Your Computer
Runtime errors may occur if the computer (particularly when your graphics driver) is not updated. You can check for updates under system settings.
Note: You may see the ‘You’re up to date’ message on opening the Windows Update screen. So, manually check for updates to ensure that everything is updated.
Workaround 5 – Re-install Microsoft Visual C++ Runtime Libraries
You may encounter the Access runtime error 32002 if the MS Visual C++ package is not installed properly or updated. In that case, uninstall the current package and install the latest one. The detailed steps are as follows:
- Open Control Panel, and click to open ‘Program and Features’. This will open a list of all the installed programs.
- Look for the Microsoft Visual C++ Redistributable Package, right-click on it and click ‘Uninstall’.
- After completing the uninstallation process, reboot your computer.
- Download and install the latest redistributable package.
If you’re still unable to open or run a macro, check if the following repair method works for you.
Workaround 6 – Repair the Access Database
Run the Microsoft Access built-in ‘Compact and Repair’ utility to fix the Access database with the problematic macro. After repairing the database, check if you can access the macro or work with it. See this Microsoft article for detailed information on compacting and repairing an Access db.
If the Compact and Repair utility fails, use an Access database repair tool to repair macros. This is where Stellar Repair for Access comes in handy. The software repairs a corrupted Access database file (MDB/ACCDB) and its components such as macros, modules, forms, reports, etc.
The Access repair tool previews all the recoverable macros and other objects, helping you to verify the data before saving it.
Conclusion
This blog outlined the reasons behind the Access error ‘Cannot open or run macro, because it is not valid’. Some reasons include MS Access crashing when working with macros, VB macro code problems, etc. The workarounds discussed in the blog might help you troubleshoot the problem. But if nothing works, use Stellar Repair for Access to restore macros and other objects from the repaired file.