VBA: Cannot find project or library

I am having a problem running an Excel/VBA program that has been working till this morning.  The error I got when I ran a macro I wrote is:

Compile error: Cannot find project or library

When I check the references in VBA editor, I find the list of references to be different than when I ran it on another machine.  I have some xla libraries on a server that I've linked to the application, and the libraries are being shared among my colleagues.  I tried relinking the libraries but that didn't work either.  Sometimes, I get another message saying the library is being used by another application.

Has anyone encountered this before   Any suggestions on how to fix it   It's frustrating being the error only occurs on my machine...

Thanks so much,
CWF


Answer this question

VBA: Cannot find project or library

  • Rangi

    Unfortunately, that did not work either.  The only fix I found is to open the references dialog box from VBA editor, click OK without doing anything and rerun the macro.  Then it works.  When I reopen the references dialog after this, the list of references changed to whatever it's supposed to have.  Really strange.  Any ideas
  • _Othello_

    I am having a similar issue!

    Is it possible for an ExCel Spreadsheet created with a most recent revision of an ActiveX Control to not work on a PC running a previous version of the ActiveX Control. In other words, backward compatibility not supported.

    The Error code the user recieves is a Compile Error: Can not find Project or Library. This is with respect to the 'Format' function in VBA

    With that said, we check Tools in VBA, References, it says the ActiveX Control we are trying to reference is missing. However, I am unable to delete the Reference for it says it is in use. I checked to make sure no other Miscellaneous References are checked. Both machines are identical. The only difference is in regards to the ActiveX Control.

    The PC the Spreadsheet was created on is running the most up-to-date version of the ActiveX Control. Therefore, is it possible that when the user tries to run this speadsheet in their evironment, with a previous version of the activex control, that excel wants to reference the most up-to-date version rather than the control (previous version) currently installed on the PC. Would this cause the error

    Thanks,

    Joe


  • Tonychen

    Sounds like a good workaround.  Thanks so much!

  • milanac

    Have you tried copying the libraries to each local computer



  • Khalid Naseem

    Since it sounds like each end user has access to the server, you could write a quick launch script that would check for a new version and copy the library locally if a new one exists, then launch the Excel program.  If the library is small, the batch file could simply copy the file locally each time. 

    For example:
      C:
      CD \SOME_LOCAL_FOLDER
      XCOPY /Y
    \\SERVER\TOPFOLDER\SUBFOLDER\LIBRARY.DLL .\
      START MY_EXCEL_WORKBOOK.XLS


    That simple batch file would ensure that the local library is always up-to-date, and likely would require far less cumulative bandwidth than accessing the DLL remotely.

    Hope this helps,
    Josh Lindenmuth



  • Nurax

    Big Smile
    Thank you for shring this info- I spent 2 hrs on this site trying to find anything on this exact problem- ever try to get an answer about how to make an .exe file from an Excel vba project - well don't , they don't know apparently.
    thanks again
    ed

  • Arinaya

    Ok, I see what you are suggesting.  You are saying that I should use a local copy instead of a copy on the server.  So that would mean every time I release a new version of the library, I would need to copy the library to every machine.  Is this the only way around it   Sounds like there's an issue with remote libraries...

    Thanks for your suggestion though.

    (I am fairly new to writing libraries.  Thought I have it all figured out... Sad)

  • bjboo

    What I did in similar situations in the past (note these were all the same version of Excel):
     - On the development machine, put all referenced DLLs in one folder (e.g. c:\company_name\project_name\)
     - In VBA, set references by browsing to location instead of selecting from list
     - Save Excel program
     - Copy DLLs to remote computers, ensuring they are in the exact same location as the development machine
     - Copy and run Excel program

    Following the above steps, I've never seen this problem.  Where I have seen it is when the application is looking for DLLs in a location that doesn't exist, or if a different version of one of the referenced DLLs exists on the user's machine (e.g. referencing DAO 3.6 but they only have DAO 3.5 or something similar ... you can see how long ago I worked with this by that example Big Smile).

    Hope this helps,
    Josh Lindenmuth



  • Mark Hopkins - MSFT

    Hi,

    This forum is for VB.Net questions only, sorry.

    Please see.>>

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=551512&SiteID=1

    In future please try to use the MAIN VBA forum here.>>

    http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=74&SiteID=1

    or this use this VBA forum.>>>>

    http://www.programmersheaven.com/mb/vba/Board.aspx S=B20000

    Regards,

    S_DS



  • VBA: Cannot find project or library