+ Reply to Thread
Results 1 to 12 of 12

How to check if Class Module is installed/activated?

  1. #1
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    How to check if Class Module is installed/activated?

    I have an add-in that uses a custom class module for manipulating charts. It works fine on most computers, but some it will not load, or (possibly) can not be found.

    I start off by declaring the class at the beginning of my first module:

    Please Login or Register  to view this content.
    which works fine for the computers that recognize the module, but it throws errors on the ones that don't.

    My questions are:

    A) Is there another way to declare this so the error will not happen?
    B) Is there a way to check to see if the module is there before declaring the ChartClass publicly?

    Thanks for the help in advance.

    ~Frab
    Last edited by frabulator; 03-31-2021 at 07:49 AM.

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

    Re: How to check if Class Module is installed/activated?

    You could use late binding and declare as an object. Elsewhere in you code you would still need to check for the presence of the addin in order to create a new instance of the object

    Please Login or Register  to view this content.
    As the object is now an Object, rather then a CClass, intellisense will not work.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: How to check if Class Module is installed/activated?

    Quote Originally Posted by Andy Pope View Post
    You could use late binding and declare as an object. Elsewhere in you code you would still need to check for the presence of the addin in order to create a new instance of the object
    Thank you for your prompt reply, but that did not work for me. I tried doing a late binding by declaring the CClass as an Object and a Variant. Both yielded the same result, which was nothing. When going with these methods the add-in acts like the CClass Class Module doesnt exist?

    I am using this to set the Object to a CClass, is this correct?

    Please Login or Register  to view this content.

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: How to check if Class Module is installed/activated?

    Is all the code in the same workbook as the class module, or are you using references between projects?
    Rory

  5. #5
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: How to check if Class Module is installed/activated?

    Quote Originally Posted by rorya View Post
    Is all the code in the same workbook as the class module, or are you using references between projects?
    It is all contained inside the same workbook/add-in.

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

    Re: How to check if Class Module is installed/activated?

    If it's all within the addin why would it not work sometimes? Why would the module not be there?

    Your explanation of the situation has me confused

  7. #7
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: How to check if Class Module is installed/activated?

    Quote Originally Posted by Andy Pope View Post
    If it's all within the addin why would it not work sometimes? Why would the module not be there?

    Your explanation of the situation has me confused
    Me too. Thats why I brought it here.

    The code runs great on (I assume) roughly 75%, but the other quarter, the code holds up and acts like the Class Module isnt even there.

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

    Re: How to check if Class Module is installed/activated?

    Does your code include references to other libraries that may not be present on those PCs?

  9. #9
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: How to check if Class Module is installed/activated?

    Quote Originally Posted by Andy Pope View Post
    Does your code include references to other libraries that may not be present on those PCs?
    I thought about that right before you typed it.

    In the beginning of the CClass, I have the following declared:

    Please Login or Register  to view this content.

    The mentioned dll is part of the vb6runtime that is optional to install. If that is not found on the machine, then the code could lockup and jump out of the CClass, acting like it didnt exist.

    Would I be correct in assuming this?

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

    Re: How to check if Class Module is installed/activated?

    If the library is not found then compile errors will appear. Some/most times the error raised is not related directly to the missing library.
    You see lots of posts where the Len function reports a compile error when a library reference is missing

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: How to check if Class Module is installed/activated?

    What are the actual error messages that you are getting?

  12. #12
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: How to check if Class Module is installed/activated?

    Quote Originally Posted by rorya View Post
    What are the actual error messages that you are getting?
    Looking back at my screen shots, it looks like the first error is a compile error inside the CClass. Then other errors come after that saying that it cannot find CClass.

    So, I guess that is my answer. Something inside the CClass is working for most people but not for all.
    Last edited by frabulator; 03-30-2021 at 10:21 AM.

+ 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. [SOLVED] Class Module Events : How to refering to individual class members
    By kev_ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2020, 06:27 AM
  2. Class Module to design a class based on an autoshape (arrow)
    By BluesEnd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-18-2017, 07:23 AM
  3. Place code in userform, module or class module
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2017, 07:04 AM
  4. Replies: 1
    Last Post: 10-20-2014, 11:01 AM
  5. [SOLVED] Class Newbie question #2 - Check if Class already loaded/set?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-16-2014, 06:59 PM
  6. [SOLVED] ComboBox class .AddItem filled in class module
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-03-2012, 05:48 AM
  7. Replies: 1
    Last Post: 08-30-2011, 02:23 AM

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