You are currently offline, waiting for your internet to reconnect

"Can't Find Project or Library" When You Run a Macro

This article was previously published under Q166273
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
In Microsoft Excel 5.0 or 7.0, when you attempt to run a Visual Basic forApplications macro to insert a Visual Basic module into a workbook or torecord a new macro, you may receive the following error message:
Can't find project or library
When you click OK, the References dialog box appears. One or both of thefollowing items are listed in the Available References list:
MISSING: Microsoft Office 8.0 Object Library

MISSING: OLE Automation
NOTE: When you record a new Visual Basic macro, you may also receive thefollowing error message:
Unable to record.
This problem occurs when all of the following conditions are true:

  • The workbook contains a reference either to the Microsoft Office 8.0 Object Library or to the OLE Automation library.

    NOTE: If you create the workbook in Microsoft Excel 97 or if you use the References dialog box in Microsoft Excel 97 to create the reference, the workbook may contain such a reference. -and-

  • In Microsoft Excel 97, you saved the workbook in the Microsoft Excel 5.0/95 Workbook format. -and-

  • You opened the workbook in Microsoft Excel 5.0 or 7.0 and attempted to run a macro, to insert a Visual Basic module into the workbook, or to record a new macro. -and-

  • No Microsoft Office 97 program is installed on the computer on which you are running Microsoft Excel 5.0 or 7.0.
To work around this problem, use either of the following methods.

Method 1: Disable Missing References in the References Dialog Box

If the References dialog box appears when you attempt to run a macro, toinsert a macro, or to record a new macro, follow these steps:

  1. In the list of Available References, clear any check boxes to the left of references that are labeled "MISSING."
  2. After you clear all the missing references, click OK.
  3. Run the macro, insert or record a new macro.
The References dialog box does not appear.

NOTE: Save the workbook before you close it. Otherwise, the change to theReferences dialog box may not be saved. For more information, please seethe following article in the Microsoft Knowledge Base:
114627 XL: No Prompt to Save Changes After Tools Reference Change

Method 2: Remove References in Microsoft Excel 97

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. You can prevent the References dialog box from appearing in Microsoft Excel5.0 or 7.0 by removing references that are potentially missing from theworkbook while it is open in Microsoft Excel 97. The following sample macroremoves references:
   Sub RemoveLibraryReferences()       On Error Resume Next       Dim xObject As Object       Set xObject = ThisWorkbook.VBProject.References.Item("Office")       ThisWorkbook.VBProject.References.Remove xObject       Set xObject = ThisWorkbook.VBProject.References.Item("stdole")       ThisWorkbook.VBProject.References.Remove xObject   End Sub				
When you run the macro, it programmatically removes the reference to theMicrosoft Office 8.0 Object Library and OLE Automation from the workbook.You can then save the workbook in the Microsoft Excel 5.0/95 Workbookformat. When you open the workbook in Microsoft Excel 5.0 or 7.0, and thenrun a macro, insert a module, or record a new macro, the error message doesnot appear.

NOTE: You cannot run this macro in Microsoft Excel 5.0 or 7.0. The macroworks ONLY in Microsoft Excel 97.
Microsoft has confirmed this to be a problem in the Microsoft productslisted at the beginning of this article.
When you use a workbook that is saved in the Microsoft Excel 5.0/95Workbook format in Microsoft Excel 5.0 and 7.0, this problem may occur whenthe Microsoft Office 8.0 Object Library (Mso97.dll) or OLE Automation(Stdole2.tlb) is unavailable. If you install any of the Microsoft Office 97programs on your computer, the Mso97.dll and Stdole2.tlb files should beavailable.

Note that this problem occurs only if the workbook contains a reference tothe Microsoft Office 8.0 Object Library or to OLE Automation. In MicrosoftExcel 97, you can view references by clicking References on the Tools menuin the Visual Basic Editor. In Microsoft Excel 5.0 or 7.0, you can viewreferences by clicking References on the Tools menu when a Visual Basicmodule is the active sheet.
For additional information about getting help with Visual Basic forApplications, please see the following article in the Microsoft KnowledgeBase:
163435 VBA: Programming Resources for Visual Basic for Applications
XL97 XL7 XL5 8.0 Can t find project or library XL

Article ID: 166273 - Last Review: 10/10/2006 17:03:02 - Revision: 2.3

  • Microsoft Excel 97 Standard Edition
  • Microsoft Excel 95 Standard Edition
  • Microsoft Excel 5.0 Standard Edition
  • kberrmsg kbprb KB166273