Delete EXD files to fix “Object library invalid” error

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.

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

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\

EXD files

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.

This entry was posted in Technology and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

158 Comments

  1. michael
    Posted 2010/04/10 at 3:09 am | Permalink

    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!

  2. Dream
    Posted 2010/05/06 at 5:06 pm | Permalink

    Thank you!
    It helped me a lot.

  3. David Guevara
    Posted 2010/06/05 at 2:22 am | Permalink

    I spent a lot time searching for a solution, I tried your solutions and that works!! you have saved my life.

  4. Lev
    Posted 2010/06/15 at 1:46 pm | Permalink

    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.

  5. Terry
    Posted 2010/06/16 at 3:13 pm | Permalink

    This worked perfectly after installing Office 2010. Microsoft should add this routine to the installation package. Thank you very much for sharing this.

  6. Randy
    Posted 2010/07/07 at 12:21 am | Permalink

    This was a big pain as one of our PowerPoint add-ins mysteriously stopped working, thanks for the article!

  7. Sarah
    Posted 2010/07/07 at 5:17 am | Permalink

    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.

  8. IV-an
    Posted 2010/07/08 at 12:40 pm | Permalink

    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.

  9. Posted 2010/07/18 at 9:44 pm | Permalink

    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!

  10. Eric
    Posted 2010/07/27 at 9:32 pm | Permalink

    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!

  11. Abu Maryam
    Posted 2010/08/09 at 11:44 am | Permalink

    Fantastic!!! it works!

  12. shady
    Posted 2010/08/09 at 8:43 pm | Permalink

    thanks man. you did helped me

  13. Cyrus
    Posted 2010/08/18 at 9:14 am | Permalink

    Thank very much, it is a great help to me!

  14. Sean
    Posted 2010/08/23 at 12:41 am | Permalink

    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.

  15. Pegoto
    Posted 2010/08/30 at 6:31 pm | Permalink

    Great! This fixed my Excel 2010 problem!

  16. Ted Singer
    Posted 2010/08/30 at 6:52 pm | Permalink

    Deleting the .exd files fixed Reuters 3000 Xtra (Power Plus Pro) on Excel 2003. Thank you!

  17. Tommy
    Posted 2010/08/30 at 8:37 pm | Permalink

    Thanks! It helped me so much!

  18. Nataraj
    Posted 2010/09/02 at 9:56 am | Permalink

    Awesome. It works and its very simple. Hats off to you.

  19. Frank
    Posted 2010/09/02 at 5:50 pm | Permalink

    Thank you kindly….Worked perfectly as I was having trouble opening attachments…

  20. Matteo
    Posted 2010/09/08 at 5:09 pm | Permalink

    Thank you! Solved my problem

    You ‘re my hero.

  21. Vivek Vikash
    Posted 2010/09/17 at 6:14 pm | Permalink

    Thank You very much!!!

  22. Jon U
    Posted 2010/09/27 at 5:15 pm | Permalink

    Deleting the .exd file fixed SAP BPC (OutlookSoft 5.0) on Excel 2003. Thank you!

  23. Mela
    Posted 2010/10/06 at 1:40 am | Permalink

    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.

  24. Peter
    Posted 2010/10/07 at 3:43 pm | Permalink

    Briliant solution!!

    I work as IT specialist @ AkzoNobel and just made a PC user very happy with your simple but effective solution.

    Thanks!

  25. Fer
    Posted 2010/10/10 at 1:18 am | Permalink

    It helped a lot.
    Thanks man..

  26. Phoebe
    Posted 2010/10/10 at 10:49 pm | Permalink

    awesome. Was having series of problems importing to SharePoint 2010 to create list. This was the second half of the problem. Grazie!!

  27. Steve
    Posted 2010/10/13 at 5:05 pm | Permalink

    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.

  28. Mary
    Posted 2010/10/19 at 6:40 pm | Permalink

    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.

  29. Posted 2010/10/22 at 3:43 pm | Permalink

    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

  30. Posted 2010/10/26 at 6:35 am | Permalink

    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”

  31. allen
    Posted 2010/11/02 at 9:19 am | Permalink

    thanks everyone

  32. Jason
    Posted 2010/11/19 at 10:26 pm | Permalink

    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

  33. Evoleht
    Posted 2010/11/26 at 9:31 am | Permalink

    Thank you very much. it solves my problem in weeks.

  34. Carol
    Posted 2010/11/28 at 10:48 am | Permalink

    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!!!!!!

  35. Mitakkinen
    Posted 2010/12/05 at 9:27 pm | Permalink

    Thank you, man!
    You saved the day! :-)

  36. Renny
    Posted 2010/12/22 at 12:40 am | Permalink

    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

  37. Posted 2010/12/29 at 2:08 pm | Permalink

    Works! Thank you!

  38. Jason Judge
    Posted 2011/01/15 at 1:27 pm | Permalink

    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.

  39. Ricardo Mesa
    Posted 2011/01/20 at 8:27 pm | Permalink

    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.

  40. Han Liem
    Posted 2011/01/27 at 4:20 am | Permalink

    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.

  41. Anjomi
    Posted 2011/02/09 at 2:14 pm | Permalink

    Excellent post. Fixed my problem just fine. Don’t you just love MS updates…

  42. Palanivel Periasamy
    Posted 2011/02/10 at 12:02 am | Permalink

    Simple solution. It worked. Thanks…. :)

  43. Miguel Portals
    Posted 2011/02/11 at 3:04 am | Permalink

    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?

  44. Glaud
    Posted 2011/02/17 at 3:05 pm | Permalink

    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.

  45. Posted 2011/03/04 at 1:51 am | Permalink

    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!

  46. Posted 2011/03/04 at 8:14 am | Permalink

    Thanks Larry for posting the tip – I’ll keep it in mind, and it’ll probably help others who stumble upon this page.

  47. MoMFeI
    Posted 2011/03/09 at 10:36 am | Permalink

    Really thanks for the guideline.
    It is a very very very x999 worth lesson.

  48. Abhisheke Jain
    Posted 2011/03/14 at 5:38 pm | Permalink

    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 :)

  49. Harry
    Posted 2011/04/13 at 9:51 am | Permalink

    Aweosme…it worked for me! Thanks for all your help!

  50. chi
    Posted 2011/04/15 at 3:54 pm | Permalink

    YOU SAVED MY LIFE……This stuff works!!!!

2 Trackbacks

  1. [...] 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 [...]

  2. [...] [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting