Compile Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I developed the following macros using Excel 2002 running on Windows XP
Professional -

If dir("C:\File_Name.txt")<> "" then
my_data = mid(input,1,4)
Endif

When I execute the macro using Excel 1997 SR2 running on Windows 98 an error
message pops up - 'Can't find project or library'

This greek to me. Can someone tell me I have done wrong and how to rectify
this situation.

Thank you.
 
Not sure about this, but there might be the odd chance that the Mi
function was not being used in Excel/VBA 97. Try substituting you
"Mid()" in the code with "WorksheetFunction.Mid()". This assumes tha
Excel had a Mid function in 97 which you can pull into your code. Tr
it an see what happens
 
hi,
not sure but it may be a library thing.
open VB editor (Alt+F11)
goto tools>references
there will be all your librarys. i don't know which one
you are missing but most probably it's one of them.
note: it is not wise to write code in a higher version
application and expect it to run on a lower version.
most app developers try to make the apps backwards
compatible but few can make them forward compatable.
many times there are no problems with this but sometimes
there are.
 
In the VBE go to tools=>References and in the references at the top, there
should be at least one shown as MISSING. Although this is probably not
related to the MID function, that is just where Excel decides to tell you
about it. In any event, if you need this reference, then you need to fix
it by finding it on that machine using the browse button. If you don't need
it, then you should go back to your machine and the source file and remove
it there. Then save the file and redistribute.

As others have advised, you should do your development on the oldest version
of Excel that will need to use the code.
 
See Tom's response re missing references.

But I note you seem to be using Input as though its the name of a string
variable. Input is a reserved word, the name of a function used in reading
text files. You should pick a different name for your variable.
 
You are right, when the error message pops up, the function "Mid" is
highlighted. I actually forget to mention this earlier. Thank you very much
for the advice.
 
Thank you for the advice. Well now write macros using lower version of Excel.
 
Thank you very much for the advice, Tom. Will now write macros using lower
version of Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top