We have a Microsoft Word template that contains macros, which was working fine but all of a sudden in the last few days, whenever you invoke the template you get the following error:

Word has encountered a problem.
If you open the template file instead of invoking a New document from it, you get a more detailed error:

Object library invalid or contains references to object definitions that could not be found
This was obviously due to a change in our systems. After googling awhile, I found this article which explains that the error can happen after installing a certain Windows update: http://support.microsoft.com/default.aspx?scid=kb;en-us;932349. The update installs new versions of certain Visual Basic 6.0 Runtime files. The article provides a link to a cumulative update rollup which I tried, to no avail.
Upon further investigation, I found that the files had been updated fine. However, there is a corresponding EXD file that is created for each of the runtime files, when you use the controls provided by the runtime files in the Visual Basic designer. When the runtime files are updated, these EXD files are now invalid and hence this error occurs. To fix the error, you need to delete the EXD files and they will be re-created as needed.
These files should be located in the folder: %APPDATA%\Microsoft\Forms\
On Windows XP, it is usually located in:
C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Forms\
And on Windows Vista/7:
C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Forms\

It was easy enough to fix for myself, but others were having this problem – so I made a script that given the username deletes the files. I had users run the script (you can post it as a link on a webpage and as long as you use Internet Explorer and low security settings it can be invoked from there):
// Function to delete EXD files from user Application Data folder
// This is to resolve an issue with Word VBA macros that use VB runtimes, which the EXDs point to
function deleteEXDs(){
var strToPath = "%appdata%\\Microsoft\\Forms\\";
try {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var shell = new ActiveXObject("WScript.Shell");
}
catch (err) {
alert("Could not create ActiveXObject.\nThis script should be run from Internet Explorer, \n" +
"with low security settings (e.g. Intranet or Trusted Sites).");
return;
}
try {
var appdata = shell.SpecialFolders("AppData");
var strToPath = appdata + "\\Microsoft\\Forms\\";
var fldr = fso.GetFolder(strToPath);
var noEXDs = true;
for (var e = new Enumerator(fldr.Files); !e.atEnd(); e.moveNext())
{
if (fso.GetExtensionName(e.item()).toLowerCase() == 'exd')
{
noEXDs = false;
try {
var filename = new String(e.item());
e.item().Delete();
alert('DELETED ' + filename);
}
catch (err)
{
alert("Error - could not delete " + e.item() + ".\nDescription: " + err.description);
}
}
}
if (noEXDs) alert('No EXD files found.');
}
catch (err) {
alert("Error - could not clean up EXD files.\nDescription: " + err.description);
}
}
Edit 26 Oct 2010:
Thanks for all the positive comments!
I noticed that this solution of deleting the EXD files is now also being mentioned in the Microsoft KB article: http://support.microsoft.com/kb/957924/en-us
Edit 1 July 2011:
Thanks to the comment below by Paul M Edwards, I updated the script to use the AppData environment variable, so it should now work with Windows newer than XP.
158 Comments
I was getting this error message when trying to launch a custom vb routine in AutoCAD. I found the exd file in the forms folder just as your article describes. Now the error message is gone! Thanks Lessan, you are awesome!
Thank you!
It helped me a lot.
I spent a lot time searching for a solution, I tried your solutions and that works!! you have saved my life.
I got this error running an Excel VBA add-in after installing an Office 2010 component on top of an Office 2007 installation. Thanks a lot for sharing, it helped.
This worked perfectly after installing Office 2010. Microsoft should add this routine to the installation package. Thank you very much for sharing this.
This was a big pain as one of our PowerPoint add-ins mysteriously stopped working, thanks for the article!
I have Windows 7 and have also recently installed Office 2010 as an upgrade from 2007. Where would the .exd files be in this case? Do you delete the .box files too or just the .exd?
Thanks.
Big thanks for your advice!!! It helped me a lot. After installing Office 2010 over beta 2010, I started to have this error. Finally I deleted everything form “…\forms” folder and no problems anymore.
This post was hard to find, but WELL WORTH THE SEARCH! I was having this problem after installing Office 2010. I was unable to open word document attachments while still in outlook until I applies this fix. Everything works as it should now, thank you!
This was great advice! The “object library invalid” box was coming up every time I started or shut down Word 2010. I deleted the one EXD file I saw in the folder (MScomctlLib.exd) I left the .box file (winword.box) alone. Now no problems. Thanks!
Fantastic!!! it works!
thanks man. you did helped me
Thank very much, it is a great help to me!
To Sarah above, you should be able to find the exd files under:
C:\Users\Your User Name\AppData\Roaming\Microsoft\Forms
Just delete the exd files, not box files.
Thank the author again for saving our lives.
Great! This fixed my Excel 2010 problem!
Deleting the .exd files fixed Reuters 3000 Xtra (Power Plus Pro) on Excel 2003. Thank you!
Thanks! It helped me so much!
Awesome. It works and its very simple. Hats off to you.
Thank you kindly….Worked perfectly as I was having trouble opening attachments…
Thank you! Solved my problem
You ‘re my hero.
Thank You very much!!!
Deleting the .exd file fixed SAP BPC (OutlookSoft 5.0) on Excel 2003. Thank you!
Thanks so much for the fix. I am so glad that I found your site because I was using an add-in for my statistics class for Excel and this fix saved my life.
Briliant solution!!
I work as IT specialist @ AkzoNobel and just made a PC user very happy with your simple but effective solution.
Thanks!
It helped a lot.
Thanks man..
awesome. Was having series of problems importing to SharePoint 2010 to create list. This was the second half of the problem. Grazie!!
Many thanks for the top tip – I installed Camtasia on my machine and it stopped some Excel VBA working. Deleting the .exd’s fixed the problem.
Thanks so much, I was working with Oracle BI Publisher when I download OneNote 2010 on top of Office 2007. I wasn’t able to load xml data until I tried your fix. Have had a ticket with Oracle for days with no solution offered.
Hi,
My case is different, the error message I got is “the subject is not trusted for the specified action”. Deleting exd’s
did not resolve my problem.. kindly help he on this.
Thanks a lot fellow programmers… God bless!
Gil
Sorry Gil, I haven’t come across this problem yet myself. A quick Google search came up with this link that seems promising.
I searched for the error text you provided: “the subject is not trusted for the specified action”
thanks everyone
Hi guys,
I have tried this fix in 3 different computers that were having the issue when running Excel 2003, and it worked perfect.
Thanks
Thank you very much. it solves my problem in weeks.
Bless you!!! (And Sean above, for giving the slightly different path in Windows 7.) You have saved us from ongoing agony!!! Thank you! Thank you! Thank you!!!!!!
Thank you, man!
You saved the day!
Awesome! After several weeks having to work on a Win32 VM because my new Win764 box refused to run my VBA macros in Corel DRAW… you became my savior. Hail Lessan! XD
Works! Thank you!
Thank you! I have had this problem with Office 2003 for many months, without finding a solution, until now.
I had three EXD files in there, and one was zero bytes in size. I also had the exact same error message when starting up and shutting down Excel. Fixing that involved deleting an add-in file (.XLA) in:
C:\Documents and Settings\USER\Application Data\Microsoft\FormsExcel\XLSTART\
The Add-in file was dated 2004, so I guess is was not the *source* of the problem, but it does make the startup error go away so I can work out what needs to be reinstalled.
Awesome!!!! thanks a lot!!!
I had some macros running on Excel 2007, updated to Excel 2010 and was having this annoying problem, perfect solution, get rid of the exd files.
Thanks for sharing this. I have this problem after installing Office 2010 (from 2003). When I click the Help button on this error Microsoft does not provide any solution.
Excellent post. Fixed my problem just fine. Don’t you just love MS updates…
Simple solution. It worked. Thanks….
well, it actually doesn’t work for me…
I just got a new laptop and the excel macro that was working with no issue on XP/Office 2007 on my old laptop does not work on XP / Office 2007 on the new laptop… this is quite annoying
I have tried deleting all the *.EXD files
Any other idea?
Absolutely great!
I had an Excel 2007 file with pages of VBA code + xml for a custom ribbon. It stopped working when I installed Excel 2010. I could not find the problem. I deleted the .exd file and it is all fine now. Many Thanks.
I have discovered that the Object Library Invalid error can result from another cause. I read these posts, and removed the .EXD files, and got no improvement. Then I went back to my code and examined it in detail. I discovered that I had a button called BudgetIndividual, with a procedure named BudgetIndividual_Click. In another module, I had a subroutine called BudgetIndividual. This caused no problems.
But when I copied the BudgetIndividual procedure into the sheet module that contained the button with the same name, I got the Object Library error. This, as you may have noticed, is not an informative or helpful error message. And I have proven that it can have multiple causes. In this case, all I had to do was rename the procedure to BudgInd, and all was fixed!
Thanks Larry for posting the tip – I’ll keep it in mind, and it’ll probably help others who stumble upon this page.
Really thanks for the guideline.
It is a very very very x999 worth lesson.
Excellent Solution with the explaination of the problem.
Worked great for me, I had been breaking my head to solve the problem.
Just need to get the IT guys to push this to all machines in the corporation
Aweosme…it worked for me! Thanks for all your help!
YOU SAVED MY LIFE……This stuff works!!!!
2 Trackbacks
[...] deleting the mscomct2.exd file as mentioned in this two sites “Microsoft” and “lessanvaezi” but the error stil pops. I checked and the new .exd file was generated.Some Additional [...]
[...] [...]