Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Custom Class Library

  1. #1


    I would like to create an add-in with one or more custom classes. Then, as long as the add-in is loaded, I would like to be able to create objects of type "custom class" (as defined in the add-in) witin other workbooks. Is this possible?

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Sydney, Australia
    Post Thanks / Like
    1 Post(s)
    0 Thread(s)


    This is a tricky one and something which took me ages to work out when trying this before.

    In your add-in add a function like this in a standard module:-

    Public Function ReturnClass() As ProjectName.Class1
    Set ReturnClass = New Class1
    End Function

    Where ProjectName is the name of your add-in as specified in the Properties window when you select the add-in.

    Now, in the workbook where you want to use the classes try this:-

    Select a reference to the add-in from Tools, References. Then you'll be able to do this:-

    Dim c As ProjectName.Class1

    Sub test()
    Set c = ProjectName.ReturnClass
    End Sub

    I don't believe you can directly create classes defined in another project, but this seems to work well enough. Please let me know if something is unclear.


  3. #3


    Thank you very much for taking the time to help me out. I will give this a try.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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