+ Reply to Thread
Results 1 to 3 of 3

calling a class by name

Hybrid View

  1. #1
    Registered User
    Join Date
    05-08-2008
    Posts
    2

    calling a class by name

    Hi all, New guy the forum.
    I work for a company that uses Excel as a front end for a large complex application.

    what I need to do is to import a *.cls file and then ask the *.cls file for it's version. This is so I can decide if I am using the correct version.

    I can import the class, no prob. But how do you call a class when you only know it's name?
    I am calling it from a module method.

    Right now I have a class named MyClass with 1 member public sub MyMethod

    Things that come to mind;
    Static class member ( not in VB )
    Static public variable ( not in VB )

    call as a macro;
    Set VBCodeMod = ActiveWorkbook.VBProject.VBComponents("MyClass").CodeModule
    Application.Run VBCodeMod.Name & ".myMethod"

    This almost works, well seems like it should work

    Any ideas?
    thanks
    Keith

  2. #2
    Registered User
    Join Date
    05-08-2008
    Posts
    2
    Back to the top

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please read the Forum Rules and then wrap your code with Code Tags.
    what I need to do is to import a *.cls file and then ask the *.cls file for it's version.
    I'm not sure I follow your question, but why not add the version as a property of the class?
    MsgBox MyClass.Version
    If that's impossible for some reason, then if the version is in the module as a well-structured comment (e.g., ' Version = 2.6), then open the file (it's just text) and read the version.

+ 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