I can see from your screenshots that you're getting two main problems with Excel’s Solver add-in, the "SolverCode" compilation error in a hidden module and Runtime Error 1004 when running Solver-related macros.
Given that you've already a lot of workarounds, you can try addressing a corrupted Solver add-in installation or a mismatch between Solver's VBA references and your Office version.
First, close Excel completely. Navigate to:
C:\Program Files\Microsoft Office\root\OfficeXX\Library\SOLVER
(Replace OfficeXX with your version folder, e.g., Office16 for Office 2016/365.)
Delete everything inside the SOLVER folder. Open Excel, go to File > Options > Add-ins. At the bottom, select Excel Add-ins and click Go. Uncheck Solver Add-in and click OK. Repeat step 4, then check Solver Add-in again and click OK to reinstall it fresh.
This should force Excel to recreate the Solver installation from the Office core files and reset its VBA reference paths.
If after this the error persists, the root cause is often that an old Solver.xlam is still loading from XLSTART or the Roaming profile. In that case, you’ll need to clear any Solver.xlam or SolverCode modules from %appdata%\Microsoft\Excel\XLSTART and %appdata%\Microsoft\AddIns.
Please let me know the results!