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

ID: Q213524


The information in this article applies to:
  • Microsoft Excel 2000


SYMPTOMS

In Microsoft Excel, when you attempt to run a Visual Basic for Applications macro to insert a Visual Basic module into a workbook or to record 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 the following items are listed in the Available References list:
MISSING: Microsoft Office 9.0 Object Library

MISSING: OLE Automation

NOTE: When you record a new Visual Basic macro, you may also receive the following error message:
Unable to record.


CAUSE

This problem occurs when all of the following conditions are true:

  • You create a workbook that contains a reference either to the Microsoft Office 9.0 Object Library or to the OLE Automation library.

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

    -and-

  • In Microsoft Excel 2000, 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 2000 program is installed on the computer on which you are running Microsoft Excel 5.0 or 7.0.


WORKAROUND

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, to insert a macro, or to record a new macro, follow these steps:

  1. In the Available References list, clear any check boxes to the left of references that are labeled "MISSING."


  2. After you clear all the missing references, click OK.


NOTE: Save the workbook before you close it. Otherwise, the change to the References dialog box may not be saved.

Method 2: Remove References in Microsoft Excel 2000

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp

You can prevent the References dialog box from appearing in Microsoft Excel 5.0 or 7.0 by removing references that are potentially missing from the workbook while it is open in Microsoft Excel 2000. The following sample macro removes 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 the Microsoft Office 9.0 Object Library and OLE Automation from the workbook. You can then save the workbook in the Microsoft Excel 5.0/95 Workbook format. When you open the workbook in Microsoft Excel 5.0 or 7.0, and then run a macro, insert a module, or record a new macro, the error message does not appear.

NOTE: You cannot run this macro in Microsoft Excel 5.0 or 7.0. The macro works only in Microsoft Excel 97 or later.


MORE INFORMATION

When you use a workbook that is saved in the Microsoft Excel 5.0/95 Workbook format in Microsoft Excel 5.0 and 7.0, this problem may occur when the Microsoft Office 9.0 Object Library (Mso9.dll) or OLE Automation (Stdole2.tlb) is unavailable. If you install any of the Microsoft Office 2000 programs on your computer, the Mso9.dll and Stdole2.tlb files should be available.

Note that this problem occurs only if the workbook contains a reference to the Microsoft Office 9.0 Object Library or to OLE Automation. In Microsoft Excel 2000, you can view references by clicking References on the Tools menu in the Visual Basic Editor. In Microsoft Excel 5.0 or 7.0, you can view references by clicking References on the Tools menu when a Visual Basic module is the active sheet.

Additional query words: XL7 XL5 8.0 XL2000

Keywords : kberrmsg kbdta KbVBA
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: July 6, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.