+ Reply to Thread
Results 1 to 5 of 5

VBA date - compile error

  1. #1
    Registered User
    Join Date
    01-08-2010
    Location
    Luxembourg
    MS-Off Ver
    Excel 2007
    Posts
    4

    VBA date - compile error

    Hi all, I'm using code below in a macro to show a popup box if the date is not equal to today. (date in cell g2 of the excel file)

    Works on my computer, but for one friends, when he tries to run it, he got an error message "Compile error: Can't find project or library" pointing to Date.

    Can someone help on this ?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: VBA date - compile error

    Hi Dawnali,

    welcome to the forum.

    In the VBE, click Tools - References and make sure that at least the following libraries are selected/ticked

    Visual Basic for Applications
    Microsoft Excel 12.0 Object Library
    Microsoft Office 12.0 Object Library
    OLE Automation

    Then run the code again.

    hth

  3. #3
    Registered User
    Join Date
    01-08-2010
    Location
    Luxembourg
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA date - compile error

    Hi teylyn,

    thanks for your reply. I checked this, all the mentioned libraries are ticked, plus another one called "MISSING: Microsoft Windows Common Controls-2 6.0".
    However, the code still does not work.

    Note if it can help, the system did not recognise the Chr(13) either, when I replaced it with vbNewLine, that was fine.

    Would there be something else than "Date" that I can use ?
    or anyother proposal ?

    Thanks for your help !

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: VBA date - compile error

    You need to resolve the missing library problem first.

    You could just try unchecking it. But if you have code that referenced the library you will still get errors.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    01-08-2010
    Location
    Luxembourg
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA date - compile error

    Thanks for your advice. I corrected 2 things (which both solved that issue, even when taken separate).

    solution 1 : replace the mention "Date" by "VBA.DateTime.Date"
    solution 2 : downloaded and installed component MSCOMCT2.OCX (not provided with Excel 2007)

    In case this might be usefull to anyone, here is the link where I downloaded this (in french sorry) http://excel.developpez.com/outils/?...roles#MSCOMCT2

    Thanks all !

+ 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