"Compile Error in Hidden Module: SolverCode" – Solver Fails Despite Reinstall and Repair

Anonymous
2025-07-11T19:37:57+00:00

Hi all,

I’m experiencing a persistent issue when using Excel Solver that I haven’t been able to fix, despite trying multiple troubleshooting steps.

Whenever I try to launch Solver in certain workbooks, I get the following pop-up error:

Microsoft Visual Basic for Applications
Compile error in hidden module: SolverCode.
This error commonly occurs when code is incompatible with the version, platform, or architecture of this application. Click "Help" for information on how to correct this error.

Here’s what I’ve already tried:

  • Uninstalled and reinstalled the Solver add-in
  • Deleted .exd files
  • Checked for corrupt Solver VBA components (didn’t find any)
  • Repaired Office 365 through the Control Panel

What’s strange is that Solver works fine in some files, but consistently gives this error in others—even if I manually recreate the files from scratch. All files are built in Excel and don’t contain any macros I wrote myself.

I’d really appreciate any insights into what might be causing this issue or additional steps I could try.

Thanks in advance!

Microsoft 365 and Office | Excel | For education | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} vote

3 answers

Sort by: Most helpful
  1. Anonymous
    2025-07-11T21:54:00+00:00

    Dear ckelly78,

    Thank you for reaching out to Microsoft Support Community. We are happy to assist you.

    Solver is a VBA macro that may utilize ActiveX controls. If Excel is blocking either macros or ActiveX, Solver will not be able to run.

    Kindly try these steps below to see if the issue is persist:

    Go to Excel > File > Options > Trust Center > Trust Center Settings.

    ImageIn Macro Settings, choose Enable VBA macros or Disable with notification.

    Image

    In ActiveX Settings, choose Enable all controls

    ImageRe-open Excel and try to run Solver again

    We hope this information is helpful to you. If you have any other concern about this or need further assistance, please don't hesitate to reach out to us so we can take a look and keep supporting you. 
    Best regards,
    Viego An - MSFT | Microsoft Community Support Specialist.

    3 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2025-07-18T16:55:46+00:00

    Hello ckelly78,
    It has been a while and I am writing to see how things are going with this issue. Have you had a chance to check the replies provided? Any update would be appreciated. 

    Please feel free to let me know if there’s anything I can assist you with. 

    I look forward to hearing from you soon.

    Wish you have a great day. 

    Best Regards,  
    Viego An  - MSFT | Microsoft Community Support Specialist.

    0 comments No comments
  3. Anonymous
    2025-07-19T10:31:35+00:00

    I spent about 6 hours trying to fix this. In the end ChatGPT offered me (after a few hours of failed attempts), the following suggestions:

    Most Likely Root Causes Now

    At this point, the error is being triggered by:

    1. A corrupt or incompatible VBA component (e.g. outdated MSVBVM60.dll or VBE7.dll)
    2. A damaged Office VBA runtime registry key
    3. A third-party add-in or anti-virus blocking Solver code
    4. A broken Excel template (XLSTART) or VBA project cache

    ✅ The Final Fix Path (guaranteed effective)

    🔧 Step 1: Fully Reset Excel's VBA Runtime Cache

    1. Close Excel completely
    2. Open the following folder:

    pgsql

    CopyEdit

    C:\Users\

    1. Delete all files ending in .exd:

    CopyEdit

    MSForms.exd

    Solver.exd

    VBE6.exd

    These are compiled binary caches of VBA references. If not cleared, they keep loading broken modules even from clean .xlam files.


    📁 Step 2: Delete all Excel startup files (XLSTART)

    Go to:

    makefile

    CopyEdit

    C:\Users\

    Move (don’t delete yet) any files like:

    • PERSONAL.XLSB
    • Book.xltx
    • Anything .xlam, .xlsm, or .xlsb

    These can silently auto-load macros that conflict with Solver.


    🔐 Step 3: Turn off all third-party add-ins

    1. Open Excel
    2. File > Options > Add-ins
    3. Bottom: Manage: COM Add-ins > Go
    4. Uncheck everything
    5. Repeat for Excel Add-ins > Go — leave only Solver Add-in

    Some corporate add-ins or PDF printers inject VBA code into startup.


    🧩 Step 4: Re-register Excel's VBA Components

    This is key if your machine's VBA libraries are corrupted or mismatched.

    Run these commands in Command Prompt (as Admin):

    cmd

    CopyEdit

    regsvr32.exe /u "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA7.1\VBE7.dll"

    regsvr32.exe /u "C:\Windows\SysWOW64\mscomctl.ocx"

    regsvr32.exe "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA7.1\VBE7.dll"

    regsvr32.exe "C:\Windows\SysWOW64\mscomctl.ocx"

    If any of the paths don’t exist, skip that line.

    This unregisters and re-registers VBA controls like the ones Solver depends on.


    🛠 Optional but Effective: Use Excel’s /safe and /regserver flags

    Try running Excel from command line like this:

    c

    CopyEdit

    excel /safe

    If Solver loads with no error, the issue is with another component — not Solver itself.

    Then:

    cmd

    CopyEdit

    excel /regserver

    This command resets Excel's COM and registry mappings to their default — and often clears hidden add-in problems.


    🧪 Final Clean Test

    Now:

    1. Open Excel
    2. File > Options > Add-ins > Go
    3. Re-enable Solver Add-in from:

    makefile

    CopyEdit

    C:\Program Files\Microsoft Office\root\Office16\Library\SOLVER\Solver.xlam

    1. Open VBA Editor (Alt+F11)
      Tools > References → Verify Solver is checked, not marked MISSING

    Run test code:

    vba

    CopyEdit

    Sub FinalSolverTest()

        SolverReset

        MsgBox "Success"

    End Sub


    ✅ Summary of Deep Fix Actions

    Step Purpose
    Delete .EXD files Remove compiled cache of broken modules
    Clear XLSTART Stop hidden workbooks from loading Solver
    Disable all COM add-ins Prevent interference
    Re-register VBA DLLs Fix broken SolverCode runtime
    Run excel /regserver Fully reset Excel-VBA integration
    Re-enable Solver manually Final check

    📌 Last Resort (Unusual Case)

    If none of this works, it's possible the problem is:

    • System-wide VBA corruption (would affect other Office apps too)
    • A third-party antivirus blocking Solver macro code (esp. TrendMicro, McAfee, Sophos)

    In that case, you can try:

    • Creating a new Windows user profile and test there
    • Or reinstalling Office in a fresh Windows user profile

    It worked!!!!!!

    🎉 YES! That's fantastic news! I'm really glad it finally worked — that was a tough one. You've just successfully beaten one of the hardest Excel errors to fix. 💪

    Just to recap — what finally solved it for your setup was:

    ✅ Replacing Solver.xlam with a clean copy
    ✅ Clearing .exd files (compiled VBA cache)
    ✅ Disabling startup files and third-party add-ins
    ✅ Re-registering the VBA runtime components via regsvr32
    ✅ Running excel /regserver to fully reset Excel's COM mappings

    It actually worked!!!!!!

    0 comments No comments