+ Reply to Thread
Results 1 to 3 of 3

Workbook_open not firing due to compile error in class module (missing library reference)

  1. #1
    Registered User
    Join Date
    03-20-2020
    Location
    Farmington, CT, USA
    MS-Off Ver
    MS Office Professional Plus 2013
    Posts
    3

    Workbook_open not firing due to compile error in class module (missing library reference)

    Hi all,
    after hours of research in the web I finally need to ask here for your help: Following problem: I try to add a reference (Outlook library) in the Private Sub Workbook_Open() event (yes, it's in ThisWorkbook) since I need early binding for getting Outlook events later in different places. Once I open my workbook I get a compile error "user-defined type not defined" in my class module here --> Private olApp As New Outlook.Application. I understand this since the Outlook reference is not yet set and this is what I exactly try to do in the Workbook_Open event. How does Excel work here? Does it first try to compile the project BEFORE it executes code in the Workbook_Open event (enableEvents is set to True)?
    Once I run the Sub Workbook_open manually, the reference is set without any problems.
    Thanks in advance for your help.

    Trying to add reference for MS Outlook Object Library when Workbook opens:

    Please Login or Register  to view this content.
    Here the Class Module "ClsAppoint" in which the compile error occurs once I open the workbook (red line):
    Please Login or Register  to view this content.
    Last edited by Alex230274; 09-23-2021 at 09:31 AM. Reason: Code added for better understanding

  2. #2
    Registered User
    Join Date
    03-20-2020
    Location
    Farmington, CT, USA
    MS-Off Ver
    MS Office Professional Plus 2013
    Posts
    3

    Re: Workbook_open not firing due to compile error in class module (missing library referen

    No ideas, comments etc. ? I can live with "Alex, you are screwed...there is no possibility to resolve/circumvent this problem"

  3. #3
    Registered User
    Join Date
    03-20-2020
    Location
    Farmington, CT, USA
    MS-Off Ver
    MS Office Professional Plus 2013
    Posts
    3

    Lightbulb Re: Workbook_open not firing due to compile error in class module (missing library referen

    I found the problem
    All buttons and checkboxes in the workbook were Form Controls and different macros were assigned to those controls. I found out that if I remove all macro assignments and reopen the workbook, the compile error disappeared and the reference was set successfully. I replaced all Form Controls by Active X Controls and everything works like a charm. Don't ask me why it didn't work with Form Controls. I'm just glad that it's working now.
    Last edited by Alex230274; 09-24-2021 at 01:28 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Compile and Add UDF to a reference Library
    By Steveapa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2015, 06:16 PM
  2. Compile error in hidden module: Module 1 when workbook opened on different machine!?
    By MathUKTeacher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2015, 04:38 PM
  3. compile error with “let” in class module
    By bsapaka in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-14-2014, 01:34 AM
  4. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  5. Make VBA Class Module Library
    By Mark Olsen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2006, 07:10 PM
  6. Compile Error: Can't find project or library (missing Add-in)
    By Trefor in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-12-2005, 10:55 AM
  7. Compile error on "Right", missing Library
    By Sige in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-30-2005, 01:05 PM

Tags for this Thread

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