You see error 400 when a macro in your PowerPoint VBA module fails to run. This error means PowerPoint cannot complete the operation because of a runtime problem in the code. The cause is often a reference to a missing object, a corrupted module, or a conflict with a third-party add-in. This article explains why error 400 occurs and provides step-by-step methods to fix it in custom VBA modules.
Key Takeaways: Fix Error 400 in PowerPoint VBA
- Alt + F11 > Debug > Compile VBAProject: Finds syntax errors and missing references that cause error 400.
- Tools > References in VBA editor: Uncheck broken or missing library references that trigger runtime error 400.
- Safe mode (powerpnt /safe): Disables all add-ins to test if a third-party add-in is causing the error.
Why PowerPoint Macro Error 400 Occurs in VBA Modules
Error 400 is a generic runtime error in VBA. It appears when the macro tries to execute an instruction that PowerPoint cannot process. The most common root causes are:
Broken Object References
When you write a macro that references a specific slide, shape, or chart, the reference must exist at runtime. If the object was deleted, renamed, or never created, PowerPoint throws error 400. This happens frequently when you copy code from one presentation to another without adjusting object names.
Corrupted VBA Module
A VBA module can become corrupted after repeated editing, especially if you copy and paste code from untrusted sources. Corruption may introduce invisible characters or broken line endings that prevent the macro from compiling correctly.
Add-In Conflicts
Third-party add-ins can intercept VBA calls or change the PowerPoint object model. When an add-in modifies how PowerPoint handles macros, error 400 may appear even if the code is correct.
Missing Library References
VBA modules often rely on external libraries such as Microsoft Forms 2.0 or Microsoft Office Object Library. If a referenced library is missing or its version changed, the macro cannot bind to the required objects and error 400 occurs.
Steps to Diagnose and Fix Macro Error 400 in PowerPoint
Follow these methods in order. Start with the simplest fix and move to more advanced steps only if the error persists.
Method 1: Compile the VBA Project
- Open the VBA editor
Press Alt + F11 in PowerPoint to open the Visual Basic for Applications editor. - Run the Compile command
Click Debug on the menu bar, then select Compile VBAProject. PowerPoint scans all modules for syntax errors and missing references. - Read the error message
If compilation fails, PowerPoint highlights the problematic line. Fix the syntax error or add the missing object. Repeat until compilation succeeds without errors.
Method 2: Check and Remove Broken References
- Open the References dialog
In the VBA editor, click Tools > References. - Identify broken references
Look for items marked with MISSING. These references point to libraries that are not installed or have been moved. - Uncheck the broken reference
Clear the checkbox next to any MISSING reference. Click OK. - Recompile the project
Press Alt + F11 to return to the VBA editor. Run Debug > Compile VBAProject again. If no errors appear, test the macro.
Method 3: Test Macros in Safe Mode
- Close PowerPoint completely
Make sure no PowerPoint windows are open. - Start PowerPoint in safe mode
Press Windows + R, typepowerpnt /safe, and press Enter. PowerPoint opens without any add-ins. - Run the macro again
Open the presentation that contains the custom VBA module. Run the macro. If error 400 does not appear, a third-party add-in is the cause. - Disable add-ins one by one
Exit safe mode and restart PowerPoint normally. Go to File > Options > Add-ins. Click Go next to PowerPoint Add-ins. Uncheck add-ins one at a time and test the macro after each change.
Method 4: Export and Reimport the VBA Module
- Export the module
In the VBA editor, right-click the module name in the Project Explorer. Select Export File. Save the file as a .bas file on your desktop. - Remove the corrupted module
Right-click the module again and choose Remove Module. Click No when asked to export before removing. - Import the clean module
Right-click anywhere in the Project Explorer. Select Import File. Choose the .bas file you saved. - Recompile and test
Press Alt + F11, then Debug > Compile VBAProject. Run the macro to confirm the error is gone.
Method 5: Repair Office Installation
- Open Control Panel
Press Windows + R, typecontrol, and press Enter. - Select Programs and Features
Find Microsoft 365 or Office in the list. Right-click it and choose Change. - Run Quick Repair
Select Quick Repair and click Repair. Follow the on-screen instructions. If the error persists, run Online Repair instead.
If PowerPoint Macro Error 400 Still Appears After the Main Fix
Error 400 appears only on specific slides
The macro probably references a shape or object that exists on some slides but not others. Open the VBA editor and set a breakpoint on the line that accesses the object. Run the macro and step through the code with F8. When the debugger stops, check the Immediate window for the object name. Add an If statement to verify the object exists before using it.
Error 400 appears when the macro tries to save
The file format may not support macros. Go to File > Save As. Under Save as type, select PowerPoint Macro-Enabled Presentation (.pptm). If you save as .pptx, PowerPoint strips all VBA code and error 400 will appear when the macro tries to run.
Error 400 appears after copying code from another presentation
The copied code may contain references to objects that exist only in the source file. Open the VBA editor and review each line that uses ActivePresentation.Slides or ActiveWindow. Replace hard-coded slide numbers with variables or loop through all slides. Use a For Each loop to avoid referencing a nonexistent slide index.
VBA Error 400 vs Other Common VBA Errors in PowerPoint
| Item | Error 400 | Error 5 (Invalid procedure call) | Error 91 (Object variable not set) |
|---|---|---|---|
| Cause | Runtime error during macro execution | Calling a method with invalid arguments | Using an object that has not been assigned |
| Typical fix | Compile project and check references | Verify argument types and values | Set the object with Set keyword before use |
| Debug method | Debug > Compile VBAProject | Step through code with F8 | Check variable assignments in Immediate window |
Error 400 in PowerPoint VBA modules is almost always caused by a missing object, a broken library reference, or a corrupted module. Start by compiling the VBA project and checking the References dialog. If the error persists, run PowerPoint in safe mode to rule out add-in conflicts. Export and reimport the module as a final code-level fix. For system-level issues, a Quick Repair of Office often resolves the problem. After fixing error 400, consider adding error-handling code using On Error Resume Next or On Error GoTo to make your macros more robust against future runtime errors.