Compile Error in Hidden Module – VBA

Written by

Mel Jenkins

Reviewed by

Steve Rynearson

Last updated on February 5, 2022

This article will demonstrate how to fix the VBA Error: Compile Error in Hidden Module.

The VBA Compile Error in Hidden Module occurs when you are using a VBA macro in Excel which is stored in a hidden module. This might be due to the fact that you are using an External Add-in, or you may have created your own program in a previous version of Excel that no longer works in your current version of Excel. As the error says the module is hidden, then the code is most likely protected by a password and not normally available for the user to Edit.

vbacompile hidden module

Viewing a Hidden Module

The first thing to do to solve the problem would be to see if you can unhide the hidden module.

Press Alt+F11 to go to the VBE Editor.

OR

In the Ribbon, select Developer > Visual Basic.

vbacompile vbe

Note: If you don’t see the Developer Ribbon, you’ll need to enable it.

 

You will then be able to view your hidden module and fix the error.

Fixing a Syntax Error

(1) Double-click on the VBA Project that contains the hidden module, and then, (2) type in the Password.

vbacompile password

 

In the Menu, select Debug > Compile to compile the project.

vbacompile debug

 

The compile error should immediately pop up.  In this case we have a simple syntax error in the code.

vbacompile syntax error

 

Fix the error, and then click Debug > Compile again.  Once the project is successfully compiled, the compile option will be greyed out.

 

vbacompile compiled

 

Save the project to keep your changes.

 

vbacompile save file

Fixing a Missing Reference

Another common reason for a compile error in Excel is a missing reference. First, unhide your module in the same way as shown above, and then in the Menu, select Tools > References.

vbacompile error reference

 

Scroll down through the list of references to find the one you want to use.  In this case, the Microsoft Word 16.0 Object Library.

vbacompileerror add reference

(1) Select the reference and then (2) click OK and then Save your File.

Check the Excel Start up Folder

You may find that you have an add-in installed that you no longer require and these may be causing issues when you try and open Excel.

Make sure Excel is closed and then, in the File Manager of your PC, go to the XLSTART folder (this is usually located in C:\Users\USERNAME\AppData\Roaming\Microsoft\Excel\).

Remove any Add-ins (XLA or XLAM files) that you are not using.

Restart Excel.

Using Add-ins and Macros from Other Providers

If you use macros or add-ins from an external provider, chances are you are not going to have access to the password to fix your compile error. If this is the case you would need to contact the provider of the add-in or macro in order to update it to your version of Excel. To solve the compile error problem you would need to disable the add-in.

In the Ribbon, select Developer > Add-ins, and then select either Excel Add-ins or COM Add-ins.

vbacompile select addins

Remove the check mark from any selected add-in that is causing combability issues, and then click OK.

Close and Re-Open Excel.

 

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as


Learn More!
vba-free-addin

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples