Excel SolverCode Fix
Tracking down HKCU type library leftovers
Note up front: the diagnosis flow and fix steps here can be handed to an AI assistant to follow directly; the text below serves as the checklist.
Excel āCompile error in hidden module: SolverCodeā
Every time Excel starts it throws āCompile error in hidden module: SolverCodeā; dismiss it and everything else works, except that Solver wonāt open.
I ran an Office online repair; the files really were rewritten, yet the error stayed exactly where it was.
The root of this class of error usually isnāt Office itself but a leftover type library registration under the per-user key HKCU\Software\Classes\TypeLib.
Uninstalling WPS or a similar third-party suite deletes files without clearing the registry, and the bad registration keeps shadowing Excelās resolution.
This post records the complete troubleshooting session ā symptom ā root cause ā reproducible diagnosis ā a fix that touches only HKCU ā verification and rollback ā as a reference for similar cases.
Whenever an Office app reports a ācompile error in hidden moduleā for some add-in at startup, or a VBA project with forms suddenly fails to compile, this framework applies.
Symptoms and blast radius
Three typical symptoms; together they make the diagnosis near certain:
The error always appears at startup, pointing at a āhidden moduleā you have never heard of (SolverCode, ATPVBAEN and the like are all VBA project modules inside Officeās own add-ins).
Online repair changes nothing; the repair tool dutifully rewrites the files under Program Files and the error doesnāt budge.
The blast radius is precise. Only the add-in that depends on the broken thing fails (Solver wonāt open from the Data tab); the rest of Excel is perfectly normal.
The āhidden moduleā is nothing mysterious: Solver itself is Office16\Library\SOLVER\SOLVER.XLAM, an add-in macro with a VBA project.
Excel loads it automatically at startup, and a VBA project is compiled as a whole before its first use; compiling requires resolving every COM type library in the projectās reference list.
Any single reference that fails to resolve aborts the whole compile, and what the user sees is that vague ācompile error in hidden moduleā.
So when diagnosing, look for which reference fails to resolve and why; there is no need to chase the āmoduleā itself.
Root cause: type library leftovers in HKCU
COM type library registration on Windows lives in three places: the real machine-level HKLM\Software\Classes\TypeLib, the per-user HKCU\Software\Classes\TypeLib, and the merged virtual view HKCR the system builds from them.
The merge rule gives HKCU priority.
When the same GUID is registered on both sides, the HKCU value shadows HKLM.
The design lets users without admin rights ābring their ownā registration; the side effect is that any third-party software writing a type library registration into HKCU, then getting uninstalled with files deleted but registry left behind, keeps that broken registration pressed on top of the good one.
In my case the culprit was WPS: it had written its own RefEdit control type library into HKCU ({00024517-0000-0000-C000-000000000046}, the control behind the āTarget cell / Variable cellsā collapsible boxes in Solverās parameter dialog).
Uninstalling WPS deleted the files, but the leftover registration still points at a ...\WPS Office\...\refedit.dll that no longer exists.
When Excel loads SOLVER.XLAM it resolves RefEdit 1.2 through the registry, gets TYPE_E_CANTLOADLIBRARY 0x80029C4A, and compilation stops there.
That also explains why online repair does nothing: it only rewrites files under Program Files and machine-level (HKLM) registration, never cleaning per-user HKCU leftovers.
And in the merged HKCR view HKCU wins, so the bad registration keeps shadowing resolution.
The layer being repaired was not the broken one.
Beyond that there is usually a batch of collateral damage to handle as well: junk type library registrations piled up in HKCU (random GUIDs pointing at %TEMP%\VBE\*.exd caches or paths of uninstalled programs), stale .exd caches left by old components under C:\Windows\Temp\VBE, and on Click-to-Run installs of Office possibly a missing projection of the real HKLM against the C2R source store.
Diagnosis: let the bad registration show itself
Approach: rule out file and add-in registration problems first, then extract the add-inās VBA project reference list, verify each reference in turn, and corner the fault onto one specific GUID.
flowchart TD
S0["Startup shows Compile error in hidden module: SolverCode"] --> S1["1. Check add-in registration at startup (OPEN values)"]
S1 -->|"registration clean"| S2["2. Check the file itself: timestamp and publisher"]
S2 -->|"file is good"| S3["3. Check the other load paths"]
S3 -->|"all clean"| S4["4. Delete .exd caches and retest"]
S4 -->|"still failing"| S5["5. Unpack the .xlam, extract the VBA reference list"]
S5 --> S6["6. LoadRegTypeLib, verify each reference"]
S6 -->|"only RefEdit 1.2 returns 0x80029C4A"| S7["7. Compare HKLM / HKCU / C2R source store"]
S7 -->|"HKCU leftover points at a deleted file"| R["Root cause confirmed: HKCU type library leftover"]| Step | Action | Result / verdict |
|---|---|---|
| 1 | Check startup add-in registration: the OPEN values under HKCU\Software\Microsoft\Office\16.0\Excel\Options | Only points at Officeās own ANALYS32.XLL, SOLVER.XLAM ā registration clean, the problem is not the add-in list |
| 2 | Check the file itself: the timestamp of root\Office16\Library\SOLVER\SOLVER.XLAM and the publisher in docProps/app.xml | Rewritten on the day of the online repair, published by Microsoft ā the file is good |
| 3 | Check the remaining load paths: user AddIns, XLSTART (both user and ProgramData), HKLM-level OPEN, older Office version keys (11.0ā15.0) | All clean ā registration ruled out |
| 4 | Delete the user %APPDATA%\Microsoft\Forms\*.exd cache and retest | Still failing ā the cache was only a symptom, ruled out |
| 5 | Unpack the .xlam (actually a ZIP), read xl/vbaProject.bin (an OLE compound document), extract the dir stream per MS-OVBA | Reference list obtained: stdole, MSForms, RefEdit control, MSO; every dialog form hooks RefEdit |
| 6 | Verify each reference with LoadRegTypeLib (not through Excel ā call oleaut32 directly) | All others pass, RefEdit 1.2 returns 0x80029C4A ā fault located |
| 7 | Compare three places: real HKLM, HKCU, C2R source store HKLM\...\ClickToRun\REGISTRY\MACHINE\Software\Classes | Real HKLM lacks the GUID; HKCU has it but pointing at a deleted file; the C2R source store has a healthy value ā root cause confirmed |
Step 6 is the key to the whole flow, and the cheapest one.
A dozen lines of Python bypass Excel and ask the registry directly:
import ctypesfrom ctypes import byreffrom uuid import UUID
def typelib_ok(guid: str, major: int, minor: int) -> bool: iid = (ctypes.c_ubyte * 16).from_buffer_copy(UUID(guid).bytes_le) lib = ctypes.c_void_p() hr = ctypes.windll.oleaut32.LoadRegTypeLib(iid, major, minor, 0, byref(lib)) return hr == 0
REFEDIT = "{00024517-0000-0000-C000-000000000046}"print(typelib_ok(REFEDIT, 1, 2)) # False means the registration is brokenOnce a suspicious GUID is found, use reg query to see where it is registered and which file it points at, then check whether that path exists:
reg query "HKCU\Software\Classes\TypeLib\{00024517-0000-0000-C000-000000000046}" /sThe default value of 1.2\0\win64 in the output is the type library file path.
Fix: touch only HKCU, back up first
Two principles.
First, every change lands in HKCU (per-user), nothing touches HKLM, no administrator needed.
Since the bad registration sits on top in HKCU, fixing or clearing HKCU is enough; HKLM was fine all along.
On a Click-to-Run machine the healthy values can be read straight from the C2R source store, which is effectively Microsoftās own backup of the correct answer.
Second, export a backup before touching anything, so a problem can be walked back:
reg export "HKCU\Software\Classes\TypeLib" "%USERPROFILE%\TypeLib_backup.reg" /yreg export "HKCU\Software\Classes\CLSID" "%USERPROFILE%\CLSID_backup.reg" /yThen run five steps in order:
Rebuild the bad registration: delete the
{00024517}key in HKCU that points at the uninstalled program, read the healthy values from the C2R source store and rebuild, rewriting all paths to the real files on this machine (e.g.C:\Program Files\Microsoft Office\root\Office16\REFEDIT.DLL, for both win32 and win64). As a .reg file it looks roughly like:Windows Registry Editor Version 5.00[HKEY_CURRENT_USER\Software\Classes\TypeLib\{00024517-0000-0000-C000-000000000046}\1.2]@="Ref Edit Control"[HKEY_CURRENT_USER\Software\Classes\TypeLib\{00024517-0000-0000-C000-000000000046}\1.2\0\win32]@="C:\\Program Files\\Microsoft Office\\root\\Office16\\REFEDIT.DLL"[HKEY_CURRENT_USER\Software\Classes\TypeLib\{00024517-0000-0000-C000-000000000046}\1.2\0\win64]@="C:\\Program Files\\Microsoft Office\\root\\Office16\\REFEDIT.DLL"Also confirm
HKCU\Software\Classes\CLSID\{00024522}(RefEdit.Ctrl) and its ProgID exist.Type library registration governs compilation, CLSID registration governs instantiation; when the latter is missing, compilation passes and the parameter dialog still wonāt open ā a separate fault of its own.
Clean the junk: walk
HKCU\Software\Classes\TypeLiband delete every registration whose default value points at a nonexistent file (%TEMP%\VBE\*.exd, paths of uninstalled programs), one by one; donāt guess from names. āDoes the path existā is the only criterion.Fill the gaps: compare against the C2R source store and the real HKLM, and top up missing type libraries with the same āread the healthy value ā rewrite the path ā write into HKCUā method, so the next add-in doesnāt hit the same problem.
Clear caches: delete the old
.exdfiles underC:\Windows\Temp\VBEand in the userFormsdirectory, so Excel regenerates them from the repaired registration.Verify: recheck every reference with
LoadRegTypeLib, then do end-to-end acceptance in Excel.
Verification and rollback
Verification has two layers.
Registry layer: run the reference list through typelib_ok from the previous section; before and after for the core references look roughly like this:
| Reference | GUID | Before | After |
|---|---|---|---|
| Ref Edit Control 1.2 | {00024517} | 0x80029C4A failure | 0x00000000 ā |
| Microsoft Forms 2.0 | {0D452EE1} | 0x00000000 ā | 0x00000000 ā |
| OLE Automation 2.0 | {00020430} | 0x00000000 ā | 0x00000000 ā |
| Microsoft Office (MSO) | {2DF8D04C} | 0x00000000 ā | 0x00000000 ā |
| Microsoft Excel 16.0 | {00020813} | 0x00000000 ā | 0x00000000 ā |
Application layer, end to end: Excel starts with no error; Data ā Solver opens the parameter dialog and the RefEdit collapsible box works.
There is one easily missed corroboration worth checking.
Whether %APPDATA%\Microsoft\Forms\RefEdit.exd gets rebuilt normally: before the fix this file could not be produced at all, a side effect of the VBA compile failing.
If it is back, the compile chain is almost certainly through.
Rollback is simple: double-click and import the two backup .reg files exported at the start of the fix section, and the pre-fix state returns.
Note that the failure returns with the rollback, because what got rolled back is exactly the fix.
These backups exist only to return you to a known state when a fix goes wrong; once the fix succeeds they have no other use.
If it recurs later, walk the checklist: first confirm no more āWPS compatibility component / VBA pluginā of unknown provenance got installed ā those are the most common writers of bad registrations under HKCU\Software\Classes\TypeLib; then recheck {00024517} with typelib_ok, where a nonzero result means the registration is broken again; then rerun the five steps of the fix section (idempotent, run after backing up); and only if it cannot be cleaned, uninstall and reinstall Office as the last resort.
Closing notes
Looking back at my own case, these are the three things worth remembering:
What the error message says and what is broken are usually not the same thing. āCompile error in hidden moduleā is broken by one type library reference in the registry.
Online repair only fixes the layer it can see. Program Files and HKLM; per-user HKCU leftovers are permanently outside its range.
The core diagnostic move is to bypass the app and verify the references directly. One LoadRegTypeLib call turns āwhich GUID is brokenā from a guess into a fact.
On machines that have installed and uninstalled WPS or another Office-compatible suite, HKCU almost certainly has leftovers; cleaning early is cleaning cheap.
And for any āafter uninstalling one program, another started reporting strange errorsā, take a look at HKCU\Software\Classes first ā it often saves an afternoon compared to reinstalling.