How to Fix “Compile Error in Hidden Module” in Excel (6 Reasons)

What Is Compile Error in Hidden Module in Excel VBA?

A Compile Error in Hidden Module is a security alert in Excel VBA. It usually occurs when the VBA code is incompatible with the version or architecture of the Excel application. When you attempt to run the code, this alert pops up.

Reason 1: Password-Protected VBA Module

If you have a password-protected VBA module, it will act as a hidden module. To resolve this, you need full access to the Excel file containing the module. Otherwise, you’ll require permission from the file’s owner.

Solution: Unprotect the VBA Module

Follow these steps to fix the error:

  • Enable the Developer tab:
    • Go to the File menu.

Choosing File Tab from Excel Ribbon

    • Select Options in the Overview Panel.

Selecting Options from Overview Panel

    • Choose the Customize Ribbon tab.
    • Check the Developer feature under Customize the Ribbon.
    • Click OK to close the Excel Options box.

Activating Developer Tab in Excel Options Wndow

  • Navigate to the Developer tab and select Visual Basic under the Code section.

Opening Visual Basic from Developer Tab

  • Right-click on the hidden module and choose VBAProject Properties.

Opening VBAProject Properties of Selected Module

  • In the VBAProject – Project Properties window, go to the Protection tab and remove the password.
  • Press OK.

Removing Password in VBAProject - Project Properties Dialogue Box

  • Your code should now run smoothly in Excel.

Read More: VBA Object Variable or with Block Variable Not Set in Excel

Reason 2: Missing References in Visual Basic Editor (VBE)

When working with Objects from different applications in Excel VBA, you need to add references to the object libraries of those applications. If specific references are unavailable, it can result in a Compile Error in Hidden Module.

Solution: Activate Missing References in VBE to Remove Compile Error in Hidden Module in Excel

To resolve this issue:

  • Open Developer > Visual Basic in your workbook.
  • Select References from the Tools menu.

Opening References from Tools Tab

  • Scroll through the list of Available References.
  • Mark the Microsoft Word 16.0 Object Library reference (or any other relevant reference) to enable it.
  • Press OK to close the window.

Activating Required Reference in References - VBAProject Window

  • Try running the VBA code again, and the error should no longer appear.

Read More: [Fixed!] Subscript Out of Range Error in Excel VBA

Reason 3: MS Excel Containing Template Files of Add-ins

Third-party Excel Add-ins, such as Adobe Acrobat PDF Maker, can enhance Excel’s functionality. However, if these add-ins are incompatible with the VBA project, they can cause a compile error in hidden modules.

Solution: Remove External Add-ins to Fix Compile Error in Hidden Module in Excel

You can address this issue from both the Excel Developer tab and the Excel Start-up Folder:

  • Remove Add-ins from Developer Tab:
    • Open Excel Add-ins from the Developer tab.

Opening Excel Add-ins from Developer Tab

    • Uncheck any add-ins that you don’t need.
    • Press OK to resolve the Compile Error in Hidden Module.

Deselcting Unnecessary Add-ins

2. Remove Add-ins from Excel Start-up Folder

Follow the steps below to remove any unnecessary add-ins from the Excel Start-up Folder.

  • Close all open Excel files.
  • Navigate to the XLSTART folder (usually located in C:\Users\USERNAME\AppData\Roaming\Microsoft\Excel).
  • Delete any unused XLA or XLAM files.
  • Restart Excel, and the error should be fixed.

Read More: Reasons And Solutions for Excel Object Required Error in VBA

Reason 4: Incorrect Syntax in VBA Code

If the previous solutions didn’t resolve the issue, there might be incorrect syntax in the VBA code.

Solution: Fix Syntax Errors in VBA Code

Follow these steps:

  • Press Alt + F11 to open the Visual Basic Editor.
  • Click on Compile VBAProject under the Debug tab while your code is open.

Selecting Compile VBAProject from Debug Tab in Visual Basic Editor

  • If there’s a syntax error, it will be highlighted.

Determining Syntax Error to Fix

  • Press OK and correct the code where indicated.
  • Open Debug again, and if the Compile VBAProject option is grayed out, the code has been successfully compiled, and the error is resolved.

Successful Compilation of VBAProject after Correcting Syntax

Read More: [Fixed!] Excel Application-Defined or Object-Defined Error in VBA

Reason 5: Unsupported Registered OCX Files

OCX files are Windows ActiveX Control files used for customizing and reusing user interface design. Unregistered or incompatible OCX files can lead to a Compile Error in Hidden Module in Excel.

Solution: Re-register OCX Files Using Command Prompt (CMD)

To solve this issue:

  • Press the Windows key + R to open the Run box.
  • Type cmd and press OK.

Opening Command Promt (cmd) in Run

  • Depending on your system version type one of the following commands in the Command Prompt (cmd):

Inserting Required Command to Re-register OCX Files

  • For 32-bit systems:

regsvr32 -u c:\windows\system32\mscomctl.ocx

regsvr32 c:\windows\system32\mscomctl.ocx

  • For 64-bit systems:

regsvr32 -u c:\windows\syswow64\mscomctl.ocx

regsvr32 c:\windows\syswow64\mscomctl.ocx

Run Excel, and the Compile Error in Hidden Module should no longer occur.

Read More: [Fixed!] Invalid Forward Reference in VBA

Reason 6: Unwanted .exd Files in Device Folders

.exd files stored in device folders allow faster access to additional controls. However, misalignment with the application can cause a compile error.

Solution: Delete .exd Files

  • Open the Run dialog.
  • Type %appdata% and press OK.

Typing %appdata% Command in Run

  • Navigate to the Application Data Folder.

Selecting Microsoft Folder from List

  • Open the Microsoft folder.

Opening Forms Folder

  • Inside the Forms folder, select the files and delete them.

Deleting selected .exd Files

  • Restart Excel, and the error will be resolved.

Read More: [Fixed!] Unable to Set the Visible Property of the Worksheet Class

How to Externally Solve “Compile Error in Hidden Module” for Excel

If the previously discussed solutions don’t completely resolve the issue, you can try the following external methods to fix the Compile Error in Hidden Module in Excel.

Method 1: Move Adobe Acrobat PDF Maker Files

If you have installed Adobe Acrobat PDF Maker on your device, then you need to relocate the file and pdfmaker.xla files to a different location.  Follow these steps:

  • Click the Windows icon and type * in the search bar.
  • Select the files and folders that appear.
  • In the All or part of the file name field type * and search for it.
  • Locate the dot & pdfmaker.xla files in the folder > right-click > choose the Cut option.
  • Paste them to a location of your choice on your Desktop to resolve the error.

Read More: Because of Your Security Settings Macros Have Been Disabled

Method 2: Update Available Latest Version of Adobe Acrobat

Ensure that your installed Adobe Acrobat software is up to date:

  • Open Adobe Acrobat.
  • Click on Help in Adobe’s window.
  • Choose Check for Updates to open the updater window.
  • If any updates are available, press Download and Install.

Method 3: Uninstall Norton Antivirus Software

To address the error, consider uninstalling Norton Antivirus Software from your device instead of updating it:

  • Press Windows + R to open the Run dialog.
  • Type cpl in Run dialog and click OK.
  • From the list, select the Norton Antivirus software.
  • Click the Uninstall button to remove the software after confirmation.

Read More: [Fixed!] Method Open of Object Workbooks Failed

Frequently Asked Questions

  1. How can I open Excel in safe mode? To open Excel in safe mode, press and hold the Ctrl button while opening the file. You can also apply the safe switch (e.g., excel.exe /safe) when starting the program from the command line.
  2. How can I repair MS Excel when it crashes? Microsoft has introduced the MS Excel Repair Tool, available in all Excel versions. This tool quickly fixes crashes, sorts damaged or corrupted Excel files, and recovers erased or lost data from spreadsheets, cell comments, pivot charts, functions, and formulas.

Related Articles:

Get FREE Advanced Excel Exercises with Solutions!
Sanjida Mehrun Guria
Sanjida Mehrun Guria

Hello! Welcome to my blog. I have completed my Bachelor in Architecture from Ashanullah University of Science & Technology, Dhaka. I am a passionate, goal-oriented person with an immense thirst for knowledge and an attitude to grow continuously. Besides Architectural work, I find it very enthusiastic to work in Excel blogging. Exceldemy is a platform where I have got the opportunity to flourish my skill in Microsoft Excel and therefore, here I will be posting blogs related to... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF