The VBA runtime error 432—"File name or class name not found during automation"—occurs when your script references a missing object, module, or reference in Excel, Access, or another Microsoft Office app. This happens when you try to use a class, function, or reference that doesn’t exist in the active environment, often due to incorrect setup, missing DLLs, or outdated libraries. The quickest fix is to restore proper VBA references, but deeper issues may require reconfiguring your workflow.
What You'll Need
- Access to the Excel workbook or application where the error occurs (Excel 2013+ recommended for modern VBA support).
- Administrator rights (to modify system-level references).
- A secondary Excel file (for testing reference changes without corrupting the original).
- Microsoft Visual Basic Editor (VBE) open (press
Alt+F11in Excel).
Step-by-Step
- Verify the Missing Reference
- Open your VBA project in the VBE (
Alt+F11). - In the Project Explorer, expand
Microsoft Excel ObjectsorYourWorkbookName. - Right-click
Microsoft Excel XX.X Object Library(e.g.,Microsoft Excel 16.0 Object Library) and selectAdd Reference. If this library is missing, the error stems from a broken reference setup. - Check the References window (
Tools > References). If any Microsoft-related entries (e.g.,Microsoft Scripting Runtime,Microsoft Visual Basic for Applications Extensions) are missing or crossed out, add or reinstall them. For Windows systems: Ensure they’re installed via theMicrosoft Office Toolspack or update Office viaControl Panel > Programs > Programs and Features.
- Open your VBA project in the VBE (
- Reinstall Missing DLLs or Libraries
- If the error persists after adding references, the system DLL might be corrupted. Use
DLL.exe /i(Windows System File Checker) to scan and repair system files:System32>dllchk.exe /scan(run as admin). - For Office-specific issues, reinstall the Office suite or re-add the
Microsoft.Office.XXXassemblies via Command Prompt (as admin):regsvr32 /u /nmsa C:\Windows\SysWOW64\OLEAUT32.dllReplaceOLEAUT32.dllwith the missing DLL from the Office installation folder (e.g.,C:\Program Files\Microsoft Office\Root\Office16).
- If the error persists after adding references, the system DLL might be corrupted. Use
- Fix the VBA Project Itself
- Open the problematic workbook and save it as
.xlsm(macros-enabled) if it’s not already. Ensure no VBA errors exist in the project by runningTools > Error Checking. - If the error occurs in a third-party add-in, disable the add-in in
File > Options > Add-ins(uncheck the name) and test if the error vanishes. - If the issue is in a custom class module, verify the class name matches exactly in both the module’s
Class Moduletab and the code. Capitalization matters:Public Sub Test() Dim obj As New MyClass ' Must match the class name exactly! obj.DoSomething End Sub
- Open the problematic workbook and save it as
- Restart and Test Clean Environments
- Close all Excel instances and restart your PC. Sometimes cached references cause conflicts.
- Create a fresh blank workbook and paste the macro code into a new project. If the error disappears, the issue is environment-specific and likely tied to the original file’s corruption.
- Reinstall VBA Components
- If all else fails, reinstall the VBA editor and Office components:
- Uninstall Office from
Control Panel > Programs. - Download the latest Office installer from Microsoft’s website (verify for your Office version).
- Restart your PC after installation.
- Uninstall Office from
- If all else fails, reinstall the VBA editor and Office components:
If That Did Not Work
If VBA error 432 persists after the above steps, consider:- Checking your system’s date/time settings (Windows may fail to load certain DLLs if incorrect).
- Running
msiexec /f [OfficeInstallerPath]to repair Office silently. - Falling back to VBA 6.0 (legacy) if the error involves older Office versions, though this is rarely necessary today.
Common Mistakes
- Forgetting to Update References: Skipping the
Tools > Referencesstep after adding DLLs or Office reinstallation leaves the project broken. - Case-Sensitive Class Names**: VBA is case-sensitive. A typo in the class name (e.g.,
MyClassvsmyclass) will trigger error 432 during automation. - Corrupt Office Installation**: Reinstalling Office without removing old versions may leave DLLs in conflict.
- Running as Non-Admin**: Some DLL repairs require elevated permissions. Always run repair tools as Administrator.
Tips
- Use a Test Workbook**: Always replicate the error in a clean file before troubleshooting the original project.
- Check the Error Window**: Click the
Debugbutton in VBE and examine the line number where the error occurs. This pinpoints the exact reference issue. - Enable Macro Security**: Go to
File > Options > Trust Center > Macro Settingsand verify macros are enabled for the relevant workbook. - Use Online References**: For third-party VBA libraries, download them directly from trusted sources (e.g., CodeProject) and add the path manually via
Tools > References > Browse.... - Backup First**: Always save a backup before reinstalling Office or running system tools.
Troubleshooting
- Error Occurs When Opening Excel
- Restart your PC and try again. This clears cached references.
- Open a secondary Excel file to test if the error is workbook-specific or system-wide. If it’s workbook-specific, the issue is in that file’s VBA code or missing references.
- Error After Implementing a New Add-In
- Disable add-ins temporarily and re-enable them one by one to isolate the culprit.
- If the add-in is from a third party, check its documentation for compatibility requirements.
- Error Persists After Reinstalling Office
- Use the
repairoption in the Office installer (not just uninstall/reinstall). - Run
sfc /scannowin Command Prompt as Administrator to check system integrity.
- Use the
Frequently Asked Questions
Why does VBA Error 432 keep happening even after reinstalling Office?
Even after reinstalling Office, residual DLLs or cached references might remain. Uninstall Office completely (via Control Panel > Programs > Add/Remove Programs), delete leftover files in C:\Program Files\Microsoft Office, then reinstall. Additionally, check if your system’s date/time is synchronized correctly—incorrect timestamps can prevent DLL loading.
How do I fix VBA Error 432 in Excel 2016?
For Excel 2016, ensure the Microsoft Excel XX.X Object Library (e.g., Microsoft Excel 16.0 Object Library) is added via Tools > References. If it’s missing, the Office installation may be incomplete. Download the latest Office update from Microsoft’s support site and install it.
Can I use third-party VBA libraries without error 432?
Yes, but you must manually add the library’s path in the References window. Navigate to the DLL or COM library’s folder and select Browse.... If the library is from an untrusted source, test it in a secondary workbook first.
What if VBA error 432 occurs in Access instead of Excel?
For Microsoft Access, the process is similar. Open the VBA editor (Alt+F11) and ensure the Microsoft Access XX.X Object Library is added. Access may also require the Microsoft Scripting Runtime reference. If the error involves a custom class, verify the class name matches exactly in both the module and the code.
Why does my VBA script work in one workbook but not another?
This usually indicates a difference in references or environment settings. Open both workbooks in the VBE and compare their References lists. Re-add any missing entries in the problematic workbook. Alternatively, create a new VBA project and copy the code over to test for compatibility issues.
Is there a way to disable VBA error 432 without fixing the root cause?
No, error 432 is a genuine runtime error. You cannot bypass it without fixing the underlying cause (missing DLL, incorrect reference, or syntax error). Using workarounds like error handling (On Error Resume Next) will suppress the error but may break functionality.