Fix: Compile Error in Hidden Module in Microsoft Excel VBA

The “Compile error in hidden module” error occurs when you open a VBA project in Microsoft Excel. It occurs when a module used in the project is hidden or protected or if the code written in Microsoft Excel is not targeting your application’s architecture. For instance, the excel file you are trying to open is targeting a 32-bit application, but you are trying to open it in a 64-bit version.

Compile error in hidden module error
Microsoft Excel VBA Compile in hidden module error

In this guide, we’ll provide instructions on how to fix this error.

Solution 1: Unprotect the VBA code module

If you are an owner and have access to the VBA code, then unprotect the module and check if the error persists. To unprotect the module, follow these steps:

  1. Open Microsoft Excel, click on the Developer tab from the top, and then click Visual Basic from the left.
    Opening Visual Basic on MS Excel
    Opening Visual Basic on MS Excel
  2. If you don’t see a Developer option on the top, click on File and select Options from the left pane.
    Navigating to Options
    Navigating to Options
  3. Click on Customize Ribbon from the left pane.
  4. Under the Main Tabs, tick Developer and click OK to save the changes.
    Enabling Developer option
    Enabling Developer option
  5. Now click on Developer and Visual Basic.
  6. Right-click the module you want to unprotect and then select VBAProject Properties.
    Opening module properties
    Opening module properties
  7. Go to Protection, remove the password, confirm the password, then click OK.
    Unprotecting module on MS excel
    Unprotecting module on MS excel
  8. Once done, now try to run the VBA code to check if the issue is fixed.

However, If you don’t have access, you’ll have to contact the owner of the Excel document to unprotect the VBA code.

Solution 2. Uncheck Missing References

Missing references in Microsoft Excel’s VBA Project can also cause “Compile error in hidden module” error. These references. These references are links to other modules or libraries, or external files (such as 2Dshape, FixDynamics object, ActiveX control), that the VBA code in your project relies on, but are not currently available.

  1. Open the VBA Excel, click on the Developer tab and then click Visual Basic to open the VBA editor.
  2. Click on Tools and click References from the options.
    Navigaing to Refferences on MS Excel
    Navigating to References on MS Excel
  3. Now find the references that start with the Missing word.
  4. If you find them, uncheck them one by one and click OK.
    Finding References with the starting word Missing
    Finding References with the starting word Missing
  5. Once done, check if the error is fixed.

Solution 3. Deselect Excel Add-ins

Third-party excel add-ins can enhance functionality of Excel. However, if these add-ins are incompatible with the VBA project you are opening they will cause compile error in modules. Therefore, to make sure there isn’t any Excel add-in interfering with our VBA project, disable them and test opening your VBA project again.

  1. To do so, open the Excel application, click on the Developer tab and then click on Excel Add-ins.
    Opening Excel Add-ins Window
    Opening Excel Add-ins Window
  2. Here uncheck the excel add-ins that you think are unnecessary.
    Unchecking unnecessary excel add-ins
    Unchecking unnecessary excel add-ins
  3. Then, try to run the VBA code to check if the issue persists.

Solution 4. Install Correct Architecture of Microsoft Excel

If the error persists, ensure your VBA code does not contain any mistakes. If you are sure there is no mistake in your code, you can finally try installing the latest version of Microsoft Excel. If you are trying to open a file written in a 32-bit version, download the 32-bit excel version to avoid this error.

ABOUT THE AUTHOR

Hamza Mohammad Anwar


Hamza Khan is an intermediate javaScript web developer specializing in reactjs, MongoDb, express nodeJs, and more. He creates faster and better applications using mern technologies.
Back to top button

Expert Tip

Fix: Compile Error in Hidden Module in Microsoft Excel VBA

If the issue is with your Computer or a Laptop you should try using Restoro which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption. You can download Restoro by clicking the Download button below.

Download Now

I'm not interested