Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

Class in separate add in?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chuck - 24 Feb 2005 17:21 GMT
I'm trying to get my head around classes ... ideally I'd like to create add
ins that contain code used by a variety of subs in other add ins.  I'm using
a progress bar form as my learning tool -- for instance ideally any sub in
any add in would be able to call up the progress bar from a single dedicated
add in; the alternative seems to be to copy the progress bar code to every
add in.

Is it possible to use a class that exists in a different add in?  When I set
up a class in one add in and add a reference to it in second, the second only
sees the first's modules and ThisDocument.  Do I need to create a sub in a
module in the first add in that allows the second to manipulate the class in
the first?

Apologies if this is a murky question.  Any guidance much appreciated...

Should I be creating mac
Jezebel - 24 Feb 2005 21:54 GMT
You can add a property to the module that instantiates and returns a
reference to the class. Eg the addin called XXX has a class called clsPBar;
in a module in the addin add code like this --

Public Property Get PBarClass() as clsPBar
   Set AddinClass = new clsPBar
End Property

Then any module with a reference to the addin can use

   With XXX.PBarClass
       ....

You'll need to modify the property code if you don't want to instantiate a
new class object with every call -- eg if you have just one instance shared
by all callers.

> I'm trying to get my head around classes ... ideally I'd like to create
> add
[quoted text clipped - 18 lines]
>
> Should I be creating mac
Chuck - 25 Feb 2005 14:59 GMT
Thanks Jezebel, -- I'm able to see the subs in the add in's class from the
calling macro now.  Am I correct in assuming that the only way I can call on
another template's classes is to make sure I have a reference to that
template in my calling project?  Or is there another way of accessing another
template's classes without ticking off a reference to it?

Thanks again...

> You can add a property to the module that instantiates and returns a
> reference to the class. Eg the addin called XXX has a class called clsPBar;
[quoted text clipped - 35 lines]
> >
> > Should I be creating mac
Jezebel - 25 Feb 2005 22:50 GMT
Yes, you have to have a reference to it.

> Thanks Jezebel, -- I'm able to see the subs in the add in's class from the
> calling macro now.  Am I correct in assuming that the only way I can call
[quoted text clipped - 55 lines]
>> >
>> > Should I be creating mac
Chuck - 28 Feb 2005 11:07 GMT
Thanks again for your help, it's working fine...

> Yes, you have to have a reference to it.
>
[quoted text clipped - 57 lines]
> >> >
> >> > Should I be creating mac

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.