[Resolved] Compile Error: Can’t Find Project or Library

Contents

What is a Project/Library:

In general, there are chances that a programming language/or the code developed uses some functions and features to build a logic that fulfills requirements. These functions and features used may be from some dynamic link libraries (.dll files) and other projects which are not referenced by default in the code. 

Such files are called as projects/object libraries which can be exceptionally included only in the required workbook documents for the developed code to run hassle-free.

A Quick Look at the References Dialogue Box

Please check out this section of images to understand the concept better.

The image below shows References menu under Tools. Click on it. Go to Tools → References

Excel screen displaying the Tools menu, highlighting References

Here is the dialogue box from which the references can be selected. Here, we see that some references are additionally selected for a specific programming code to run.

For example, we see the Microsoft HTML Object library selected in the image below. This is generally used when the macro runs a piece of code to automate some webpage built on HTML. This .dll supports all objects and properties of an HTML page so that the objects can be easily traced and actioned on (click, double click, hover, etc.).

The dialogue box basically lists all the libraries available by default. They are stored in the same path as in the image (C:\Windows\System32\). We can choose the required libraries based on the exceptional programming code we develop for any project. Apart from this, VBA also facilitates the use of external libraries. We can download and import these into the system for use. The browse button in the dialogue can help in importing and selecting them. After selecting the required .dlls, we can click on the OK button for the code to run without errors.

Dialogue box in Excel displaying all available libraries.

Missing a Project or Library

When a programming code uses the features/properties of a .dll that is not added to the Project’s references, we see a compile time error message. “Can’t find project or library.”

Error message in Excel that says "Can't find project or library"

There can be several reasons behind the occurrence of this error:

  1. Microsoft Excel issue (improper installation/version compatibility issues).
  2. The library compatibility issue. (The version of the library (set of .dlls) does not match or is not compatible with the version of Microsoft Excel.
  3. The .dll/library reference is toggled off (not selected in the dialogue box as in the 2nd image of this document).
  4. Outdated Microsoft Office—the program may not even be compatible with the operating system.
  5. A referenced project or an object library that is used by the programming language is found missing. These are generally displayed with the prefix “MISSING” in the references dialogue box.

Possible Solutions to the Compile Error

Remove the Missing References in the References Dialogue Box

Example of “Microsoft Excel 10.0 Object Library," a .dll that seems to be missing.
For example, in the image above “Microsoft Excel 10.0 Object Library” is a .dll that seems to be missing. Deselect it (toggle off) and click on the OK button to close the dialogue box. This solves the error.

Remove the Missing References in the References Dialogue Box

The removal of a missing object library as mentioned above may not work if the object library (.dll) is required by the program. In that case select the missing libraries one by one using the browse button and ensure that they are replaced/added to the set of references. Toggle them on and then click on the OK button to close the window.

Re-register the Missing Libraries One By One

In case the missing library is a required .dll for the developed code, and the previous two solutions do not work try re-registering the missing library file . It can help resolve the issue.

The .dll files are generally placed in a path like this. Open the folder to view it. Sometimes it might be in the OFFICE 16 or a similar folder directly.

Path where .dll files are placed.

Now, open the run window and type the path along with the .dll name as below:

Run window with the path along with the .dll name as below:

Click on Enter. You will see the “re-registration successful” message for the added .dll. This paves way to solve the compile error.

However, without adding the required references in the dialogue box, the code is not going to run. So, go back to the Tools à References dialogue box in the VBA editor and select the references that support the features called out in the code.

Once this is done, the program must be free from the compile time error “Can’t find project or library.”

Summary

Basically, all you need to do for the code to use the required but unavailable reference is to make it easily available to the program through the object libraries. To achieve this, we can repair Excel/reinstall Excel/unregister and reregister the library files alone/change the version of the library files through any safe means.

In case the missing references are not required for the program, we can simply toggle it off as mentioned in one of the solutions.

Apart from this there may be other tools in the market which may/may not be trustworthy. I have not tried as I have not faced any such situations/need so far. Also, nowadays phishing and scamming is on the rise. So, it is better to avoid using unknown applications/tools unless known people who have personally used it, recommend it to us.

Leave a Reply

Your email address will not be published. Required fields are marked *