Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In add_in.xlam I have:

Type Quantity
    i As Integer
end type

Sub show_quant(q as Quantiy)
end sub

In another workbook, I do:

Sub load_addin()
    Dim AI As Excel.AddIn
    Set AI = Application.AddIns.Add(Filename:="add_in.xlam")
    AI.Installed = True

    Dim q As Quantity
End Sub

This doesn't work. Excel complains that the User defined type hasn't been defined yet.

So how do you declare variables of a type defined in an add in?

share|improve this question

1 Answer 1

The only way I've ever been able to get something like that to work is to follow the instructions on this page: Specifically, you have to give the vba project name a new name, and you need to add it as a reference, using that name. The website explains it better.

Another page discussing the same thing: calling-add-in-functions-from-vba

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.