View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Using classes defined in an add-in

Lieven,

If you don't want to set a reference to the add-in, you need to
declare the class variable As Object, and use Application.Run to
get a reference to the newly created object (created by the code
in the add-in). E.g,

Dim MyClass As Object
Set MyClass = Application.Run("Addin.xla!GetClass")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Lieven Mettepenningen" wrote in message
...
Hello,

I'm having the following problem. I've defined a class module

in an add-in,
and I want to use this class module in a workbook that uses

this add-in. The
name of the class is 'DictionaryClass'. But when I enter the

following line
in my workbook: 'public dict as DictionaryClass', I get a

runtime-error,
because Excel complains that it doesn't know the user-defined

type. Is there
a special syntax for such a use? I already managed to do this

for the
initialization of the object. I first entered: 'Set dict = new
DictionaryClass', but this also gave a runtime-error. I then

made a public
function in one of my code modules in the add-in that creates a
DictionaryClass-object, and returns it to the workbook, and I

called this
public function from my workbook with the notation

'Application.Run.....'.
Does anyone know if I can do a similar thing for the

declaration of the
object.

The important thing is that I use the add-in, but I DON'T want

to use a
reference to the add-in. That's also the reason why a have to

use the
"Application.Run"-syntax. Can anyone help me with this problem?

Thx,

Lieven