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.

  1. 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. I spent a lot time searching for a solution, I tried your solutions and that works!! you have saved my life.

  3. 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.

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

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

  6. 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.

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

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

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

  10. 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.

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

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

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

  14. 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.

  15. Briliant solution!!

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

    Thanks!

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

  17. 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.

  18. 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.

  19. 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

  20. 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

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

  22. Pingback: "Object Library invalid or contains references…" in Excel VBA with DatePicker - Question Lounge

  23. 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

  24. 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.

  25. 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.

  26. 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.

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

  28. 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?

  29. 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.

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

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

  32. 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 🙂

  33. OMG, you did it!! We were convinced we were going to have to go back to an older version of Excel. You saved the day. Thanks!

  34. Great! Worked for me as well! I had Office 2003 and I upgraded “only” Outlook to 2010. After that I started getting the above error at start-up for Excel. After I read your article, I deleted the MSComctlLib.exd which was the only file in that path and then restarted my Excel. The error vanished and I also saw that there was a new file created by same name “MSComctlLib.exd”.

    Thank You So Much!!

  35. OMG! Thank God i found your thread, same warning was also fixed! Thank you! 😀

  36. This is a great tip which has been very helpful.

    One addition I would like to make is that the following path will provide the correct folder location regardless of Windows version or username by using an environmental variable:

    %APPDATA%\Microsoft\Forms

  37. Instead of “USER” in the paths, you can use %USERNAME%, i.e.:

    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\

  38. You are a genius! I hit this minefield when upgrading to Eggshell 2010 and my addin in 2003/2007 fell over spectacularly. Thank you 10^6.

    Trevor

  39. Thanks so much for this. This “works a treat” as they say across the pond. How do I invoke the script? What do I need to save it as?

  40. You can save the script as a javascript file (e.g. script.js). If you then double-click on it it should work.

    You can also link to it from a web page, and if you are running Internet Explorer with low security settings when you click on the link the script will have access to the local filesystem and do what it needs to do. Of course, the low security settings should only be used in a protected environment otherwise it will expose you to dangerous scripts on the internet. So you would add only the webpage you have hosted it on (preferably on your intranet) to the Trusted Sites group, or something like that.

  41. Dear Lessan… from now on you’re my new personal hero. Thank you very much!

  42. Very Nice. This error appeared to me when I switched from Office 2000 to Office 2010. Now by deleting the EXD I do not have the problem anymore. However hope that deleting this EXD will not affect another thing,

    Sheers

  43. Hi! I’ve received the same error, but with no previous Excel upgrade. I have been using Excel 2003 on Win XP for a while.

    Only see the error when I run a particular XLS that uses lots of macros and DDE to communicate with another application. The rest of the XLSs, even those with macros,work just fine. After I receive the error message, VBA Editor stops at the definition of a sub() function.

    Any ideas? I’ve tried already deleting the .EXD files, to no avail. Thanks!

    pbertu

  44. Awesome! Thank you ! Thank you! I found this site that exactly gave me the resolution!
    Thanks dude!

  45. You have saved my sanity!!! A quick deletion of a single EXD file did the trick! Unbelievable…

  46. Thanks man, saved my day too. Bloody microsoft should do that when they run the installation routine of a new office version.

  47. Thankyou so much! Finally solved this. I too was looking at going back to an old version of Excel to solve this problem. Found nothing of value in solving this on Microsoft sites (without your references).

  48. It really works fine. This error happened after upgrade from office 2007 to office 2010. After googling in italian I found the solution here, in English. Thank you very much. My head is safe (it was my boss’s pc!)

  49. which exd files need to be deleted? I see a bunch of them but i also see some box files. do they need to be deleted too?

  50. This worked like a CHARM…thank goodness. I installed MS Project 2010 on 01/22/2012 and had tried uninstalling and going back to 2007 and nothing worked. I deleted the *.exd file and now MS Excel works perfectly.

  51. Lessan,thank you so much,I did a lot on seach solution for my issue,but only your solution does work and it is very simple,thank you so much again and god bless you

  52. Thank you very much. I wasted 3 hours trying to find an answer for this problem. Google, bing, windows support, etc, and others and not even Microsoft support for office 2010 has a clear answer. I red several website but nobody gave me a simple answer the works, until I found your solution!!

    One suggestion would be to post your solution in youtube or other high traffic website, since I am sure there are hundres of people with the same annoying problem, that would benefit from your solution. Also Microsoft should issue a warning for that specific update so people do not update the one that installs new versions of certain Visual Basic 6.0 Runtime files.

    Thank you so much.

  53. Thank you so much – this worked perfectly and now my office programs open without the error message.

  54. WOW! You’re a genius. :)) Thank u so much! I’ve been very irritated with that error until i found this solution. I don’t know how to thank u for that.

  55. Thank you so much!

    I can’t say where I work, but our tech people were going to re-image my entire machine because of these errors! Wonder why they didn’t do an Internet search to find your simple & elegant solution!

    You have saved me from some major headaches! Thanks again!

    MEC

  56. Thank you for the information. It was an easy fix and worked with my Outlook as well

  57. Many thanks for this solution Lessan! Worked perfect. Did not use the script as only 1 machine had this issue.

  58. I used the manual method and this worked. However I wanted to save your script but I do not see what file extention this is supposed to be save as. It this a batch script or some other language?

    Thanks for the post and the help.

  59. It is solved problem of pop up message “object library invalid or contains references to the object definitions that could not be found” after deleting EXD files.

    Thanks
    Murali

  60. Hi,
    Just got this error after Windows Update installed various updates to MS Office 2007 and some system updates for Windows 7 2 days ago. Tried to restore the system to earlier time, uninstall recent updates a.s.o. Then I googled the text of the error message in Word and found this solution. It worked “from scratch”.
    Thank you very much for this help, as I was not able to find any solution around.
    Nice evening 🙂
    WJ

  61. This worked perfectly for me. I had ArcGIS 9.3 installed and got the same error after that ms update…too many vba code not to get me worried. Thanks

  62. You are genious man………………GOOOOOOOOOOD Work.

    Appreciate your help………….

    Thank you…………

  63. On Windows XP, EXD files are usually located in:
    C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Forms\

    Thank you so much! Now I can use my excel spreadsheets without errors!

  64. Thankfully, yours was the first website I tried and it worked. No doubt saving me hours of frustration. THANKS!

  65. Thanks! Just saved my day! It was MSComctLib.exd … Seems that the last Windows update MS ran was problematic since I am not the only person today with this problem.

  66. Could you please let me know how to save the script and run it. i tried to go the forms folder but could not find any exd file

  67. Thank you very much! Ran into this problem today and was getting really worried that my (critical) Excel-file was corrupted. You saved me hours – really appreciated!

  68. My cousin has the same problem, i’m going to try to solve the problem. Is it enough to save the script as .js file without any change in it and will it work on double click on it?

  69. Used it today Lessan, worked great. Writers are happy. Thanks.
    Vissa OS

  70. Pingback: Pendiente Insertar control progressbar en un formulario excel 2007

  71. I had to use this fix twice recenlty on a Windows 7-64 box with Office 2007 on it.
    Other similar computers did not have this problem.
    The only thing that make this PC different is that it has Exact Globe 2003 installed – Dutch bookkeeping software.
    YMMV.
    I’ve added a short to C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Forms on the user’s desktop so he can remove the offending template files himself next time this happens.

  72. Thank you so much. You explained how to solve this problem in plain English!!! Yay! My software now works…you’re brilliant and I’m a computer novice as you can probably tell!

  73. Sorry but this didn’t work for me. What else can I try? Appreciate the help.

  74. Addendum to my previous post. Out of 4 affected PCs, the solution worked for 3 of them.

  75. Thanks – this was driving me mad as the macro was working fine for a different user on my machine. Had done a system restore & it fixed it but then the update was reapplied & it broke again.

  76. Thank you so much for this solution. I had to fix 5 machines that had this issue and the users who suddenly had this error were going into a frenzy as they could not work on their files!!!

  77. It didn’t work, whatever I tried to do. How to make it work? How to make the previously mentioned hyperlink with ie? Please answer at my mail josephs@net.hr.

  78. Perfect!. Deleted ‘MSComctlLib.exd’ present in the ‘Forms’ folder mentioned in this blog post and it worked.
    Thanks a lot.

  79. Thank you for the deleting exd files suggestion. it worked perfectly. this error has been driving me crazy.

  80. Thanks for this fix!
    It is very useful!
    I work in an IT helpdesk and I have just resolved this issue on a laptop for a user .
    Thanks to this site, I did not have to re-install Office and did not have to dispatch or anything useless thing!

  81. Great great great, thnx a lot Lessan!!! My excel is running smooth again 🙂

  82. There are no .exd files in my system, searched by file extensions. Also searched for the location mentioned by you C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Forms\, but my machine does not have Microsoft\Forms folders in AppData. It has the following folders – C:\Documents and Settings\jyarida\AppData\LocalLow\DataMngr and there is only 1 file in DataMngr it is {7CA1F051-A4FB-4143-B263-02B41E571EED}, not sure if deleting this would result in some adverse outcome, therefore I didn’t delete it. Thought if I run the script you gave may fix the problem from all locations (if not from the location you mentioned), can you please tell me how to run the script? Or, is there any other solution?

    Thanks a lot!

  83. Man … Its wonderful solution…. As other one said , it saved my life …literally…

    Thanks a lot…

    Prasad

  84. Thanks so much for this quick fix. You’ve saved me hours trying to go through our IT or Helpdesk answering a hundred useless questions and then getting put off with “we’ll get back to you”.

  85. Thanks a lot for this quick & easy fix, which was driving me crazy. Another postive feature of being part of internet comunity.

    Thanks again.

  86. it works for me.
    CORREGGERE ERRORE la libreria degli oggetti non è valida di Office 2010.
    Uscire dal programma ed andare su
    C:\Users\”nome”\Application Data\Microsoft\Forms
    Eliminare il file “la libreria degli oggetti non è valida “MSComctlLib.exd”
    Riaprire il programma !!!
    Il file si ricrea di nuovo correggendo il programma

  87. THANK YOU!!! That was THE easiest fix I’ve ever had on my computer! You guys rock!!!

  88. Hi,
    I am trying to load an COM add-in, my excel is giving me loading error.
    ———————————————————
    Could not load file or assembly ‘OSIsoft.PIDataLink.UI, Version=4.0.3.0, Culture=neutral, PublicKeyToken=c3309f0734ba2805’ or one of its dependencies. Access is denied.
    ———————————————————

    I was asked to delete EXD files, but excel ribbon is still not loading, can you help?
    Thanks

  89. Чувак, выще красавчик, на работе отдел поддержки не смог решить проблему… Спасибо большое!!!
    Thank you very much! It helped!

  90. Thank you so much.I was able to fix this issue with MS-word 2007 by deleting the .exd files.

  91. Thank you. This little problem has been plagueing me for a few weeks.

  92. Depression Causes Addiction Depression is a common cause of drug addiction and alcoholism.. read more about Ambien here: http://ambienbuyonline.biz Zolpidem drug. Can I ask if the CD he gave you was for depression or was it just a general relaxation CD?

  93. I followed your directions, but could not open the application in excel, keep getting the same error. THe application has vba excel and/or macros.

  94. Thanks a ton for your post. It helped me resolve a long pending issue. I was completely lost and clueless.

    Thanks a ton again.

    Regards,
    Prince

  95. thanks so much for this! after much frustration trying to figure out how to fix this problem, your solution took care of it in just a few seconds! 🙂

  96. OMG! You are a Rock Star! Deep thanks for directing us with this solution.

  97. I deleted the .exd files but I still get the same error message. What else can I try? This is quite urgent.
    Thanks.

  98. Thank you! Just an update for those that no longer have VB installed, trying to install the update will fail. Just skip to directly deleting the exd files

  99. that did it! Installed word 2010 alongside word 2003 on xp box and started having problems. 2003 would crush when opening, 2010 throwing ‘Object library invalid’ error. After deleting esd files both words work fine with all the macros. Great hint! Thank you much!

  100. thanks! this was very helpful… being used 3 years after you published this!

  101. i try to update my java but it says %appdata% not found.
    i read on a help forum that this is a BIG problem

    help?

  102. Works like a charm, thanks for this solution! After removing the .exd files, now Excel runs fine.

    To everyone, make sure you look in the appdata/roaming folder and not in the appdata/local folder (as described by Lessan).

  103. Hello I’m using Windows 7 64-bit Home premium with Office 2007 enterprise edition, Unfortunately I can’t find any C:\Users\Daniele\AppData\Roaming\Microsoft\Forms\. The folder /Forms doesn’t exists, thus I can’t find the .exd files to delete.
    What can I do? Please help me!
    Thx

  104. If there are no EXD files and you are still getting that error, it may be due to something else. I think there are a few other reasons for the same error message to appear. You can try searching further on Google for these – I haven’t had any experience with them myself.

  105. I Lesson, after 4 years this post is still very helpful. My situation was: I have some excel macros with a date control (DTPicker) and yesterday i need to do a change in macro and this error appear (Object library invalid or contains references to object definitions that could not be found). So, this error was created because from last time that I use the macro and yesterday I installed a application that work with VBA and probably it change the file MSComCtl2 that change the MSComCtl2.exd out of date. so, for my situation you solution works well. After delete EXD files the error missing and the new MSComCtl2.exd was generated in profile path and now I can change may macro.
    Thank you for share the problem and solution .
    Best regards, Vitor

  106. I had 2 ESD files on my “forms” folder. I deleted them and remove them from my laptop. When I reopened Word, there were once again there, in the folder “Forms”; recreated. And Word has the same problem!

    electronics…

  107. I want to thank you profusely for this article, thank you, thank you, thank you! I had a problem with excel, and I didn’t know how to resolve it, and your solution worked–thank you so much.