+ Reply to Thread
Results 1 to 5 of 5

Library Reference

  1. #1
    Forum Contributor
    Join Date
    10-25-2010
    Location
    Phoenix, Arizona, USA
    MS-Off Ver
    O365
    Posts
    202

    Library Reference

    I brought a file home from work, and started to receive an error message from the VBA code.

    Compile Error: Can't find project or library

    The code that is causing the eror is "cl" in the first line:

    Please Login or Register  to view this content.
    Does anyone know how to determine which library I need to enable?

    Can this be automatically done through VBA when the workbook opens?

    Thank you!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,415

    Re: Library Reference

    Try adding a line at the beginning of the code

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    10-25-2010
    Location
    Phoenix, Arizona, USA
    MS-Off Ver
    O365
    Posts
    202

    Re: Library Reference

    Not a programmer by trade, I have not made a practice of this in the past, and things seem to work just fine.

    What is the importance of declaring DIM for referenced objects?

    Any simple answer?

    Thanks.

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Library Reference

    Declaring variables is good practice. It helps you to catch typos in their names as well as acting as a data check if you specify the variable type.

    For your original problem, check Tools--References in the VBEditor on the machine where the problem occurred. One of the checked references will have 'MISSING' at the start.
    Good luck.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,415

    Re: Library Reference

    @PosseJohn:

    Not a programmer by trade, I have not made a practice of this in the past, and things seem to work just fine.
    and your point is? It seems that it is not the case that "things seem to work just fine". Maybe you've just been lucky.

    As OEG0 says, it is good practice. Apart from anything else, it makes you think about what variables you have and what you use them for.

    If you use Option Explicit and Dim all your variables, it can avoid hours of debugging time where a variable is misspelt or not initialised properly.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1