Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Using classes defined in an add-in

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time error '50290': Application-defined or object-defined erro Macro button Excel Discussion (Misc queries) 1 March 12th 09 10:59 AM
charting # Training classes babs Charts and Charting in Excel 0 November 4th 07 03:33 PM
Excel Classes alish Excel Discussion (Misc queries) 3 October 30th 07 01:03 PM
data classes Huidekoper Excel Discussion (Misc queries) 1 April 21st 06 04:22 PM
Counting Classes MillerK Excel Discussion (Misc queries) 0 March 10th 06 03:32 PM


All times are GMT +1. The time now is 12:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"