Sunday, December 10, 2023

VBA compilation error: Object library invalid or contains references that cannot be found

VBA compilation error

VBA compilation error


This error message can pop up for Visual Basic for Microsft Office applications (VBA) based sofwares. The issue occur if security update for 2007 Microsoft Office system is installed on machine having Office 2007. If such machine has any add-in or application based on Office 2007 viz. Word or Excel, this error message can occur.

At user interface level, it might show alternate error like "Compile error in hidden module: ThisDocument". When debugged, it leads to error "VBA compilation error: Object library invalid or contains references that cannot be found" which in turn is related to control used by VBA. This error might trigger at code lines like for e.g.

Documents.Add Template:=<Template Name>, NewTemplate:=False

To address this issue, following steps need to be followed:-

ü  Close all instances of Office applications viz. Microsoft Word or Excel on user machine

ü  Go to below folder whichever available as per Windows operating system and delete all *.exd files

·         “C:\Users\<UserId>\AppData\Roaming\Microsoft\Forms” folder
·         “C:\documents and settings\<UserId>\Application Data\Microsoft\Forms” folder
·         “C:\documents and settings\<UserId>\AppData\Local\Temp\VBE” folder

The .exd files will be re-created automatically on next usage of Microsoft Office 2007 controls through VBA.


If issue still persists, follow below steps -

ü  Click the 'Start button' (bottom left) and select 'All Programs'
ü  Click on Accessories
ü  Right click on 'Command Prompt' and select 'Run as administrator'
ü  Type in: regsvr32 /u mscomctl.ocx and press return
ü  Type in: regsvr32 mscomctl.ocx and press return
ü  Start-up Microsoft Word

If above steps doesn’t resolve the issue, then follow below steps –

ü  Uninstall Microsoft Office
ü  Install Microsoft Office

For more details on this issue, please refer Microsoft Support link.



1 comment:

  1. Someone essentially help to make seriously articles I might
    state. That is the first time I frequented your website page and thus far?

    I surprised with the research you made to make this particular post extraordinary.
    Excellent job!

    my web-site: pozby³am si蟣ellulitu

    ReplyDelete

Popular Posts 😊