"Compile Error Can't find project or library."

  • Thread starter Thread starter mike allen
  • Start date Start date
M

mike allen

I have a function that works fine in a workbook by itself, but when I
attempt to add that function to another workbook (simply combining 2 into
1), I get an error message:

"Compile Error Can't find project or library."

then it highlights in yellow the entire function line and highlights in blue
"Format" in the line:

maturitymonth = CInt(Format(maturity, "mm"))

The odd thing is it works fine when by itself. It only does this when I add
this function into a large workbook with other functions and subs and
worksheets. Any ideas? thanks, mike allen
 
Hi Mike,

In the VBE, with the problematic workbook's project selected, go to:
Tools | References
and look for any entries marked 'Missing'.

Uncheck these if they are not needed or use the browse button to locate the
reference.
 
You are missing a reference. In the VBE select Tools -> References -> and
select the appropriate reference library. If you are not sure which library
you need then reply back with more info on what exactly this function does. A
couple of good possibilities would be "Microsoft Scripting Runtime" if you
are using dictionary or file system objects, or possibly "Microsoft Active X
Data Objects" if you are using ado recordsets...
 
Solver.xla was missing. I don't know why. I use solver in other code for
another sheet, but it doesn't work anymore (I guess b/c solver.xla is
missing).

Why would missing solver.xla have anything to do with "Format"? or is it
just saying, in general, that something is wrong, not necessarily with
"Format"?

Also, how could I be missing solver.xla when I use it fairly often in this
file? How do I enable it other than re-inserting the disk (I guess I could
dig it up somewhere)?

Thanks, Mike Allen
 
Hi Mike,
Why would missing solver.xla have anything to do with "Format"?

It is typical of missing references that (apparently) random functions are
highlighted.
How do I enable it other than re-inserting the disk (I guess I could dig
it up somewhere)?

Use Start | Find to locate the path to Solver.XLA and then , as before:

Tools | References | Browse | Navigate to Solver.XLA
 
The big reason for lost references are...

1. The code was developed in one version of Excel and then run on a lesser
version. For example the code referenced ADO 2.8, but was run on a machine
that only has ADO 2.7. In this case you will get the Missing designation as
2.7 does not exist on the host machine. In this case you want to dumb down
the version of the reference on the machine you are creating on, to be able
to run on the weakest host machine.

2. The code is copied from one project to another. In this case there never
was a reference made in the secong project so the error appears (without a
missing designation).

3. Code is written on one machine that has certain addins installed (such as
solver.xla) and is then run on a host amchine without the same addin's
installed. In this case you get the missing designation as the addin can not
be found.

As for the warning message it will appear on some line of code that would
otherwise compile just fine. This is just one of those wierd thing that
happens. Similar to writing code in C where one syntax error causes a whole
pile of compile errors most of which are perfectly good lines of code.
 
Thanks so much to both of you. I do have 2 versions of excel (2000 and
2003) at work and at home.
 
Back
Top