Class functionality for multiple templates

M

mamue

Hi,
I develop in Word 2000 (VB6). I have a class that offers functionality
to multiple modules (macros). Now i have multiple templates that also
need that functionality. Instead of copying the class to each template
i search for a more comfortable way, with only one instance. Is the
only solution to create a dll file?

greetings m
 
J

Jonathan West

mamue said:
Hi,
I develop in Word 2000 (VB6). I have a class that offers functionality
to multiple modules (macros). Now i have multiple templates that also
need that functionality. Instead of copying the class to each template
i search for a more comfortable way, with only one instance. Is the
only solution to create a dll file?

greetings m

You can use Tools References in the VBA editor to set a reference to another
template and the code included there. But I don't recommend that arrangement
if you are likely to be distributing your code to other users. The full
pathname of the reference is hardcoded into your template, which means you
have no flexibility as to where the referenced template will be installed on
customer machines.

With ActiveX DLLs, once the DLL is registered, code can find it wherever the
DLL is located. The same does not apply to .dot files which you reference.
 
S

Shauna Kelly

Hi mamue

Creating a DLL is one solution, and that certainly works very well.

If you don't want to do that, you can put your class in a .dot file, load
the .dot as a an addin (ie a global template). You can call code in that
addin from your templates. In the template, in the VB IDE, use Tools >
References to create a reference to the addin. Then, you can create an
instance of the class from the template in the same way as described at the
bottom of this page: http://www.cpearson.com/excel/ClassModules.htm. It's
written for Excel, but the principles are the same.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
M

mamue

Hi Jonathan,

how can i generate those ActiveX DLLs? Do i have to copy and paste my
code to Visual Studio to build them?

greetings mamue
 
J

Jonathan West

mamue said:
Hi Jonathan,

how can i generate those ActiveX DLLs? Do i have to copy and paste my
code to Visual Studio to build them?

You would need to get hold of a copy of Visual Basic 6. The current version
of Visual Studio uses VB.NET, which is a quite different language,despite
the similarity of name.
 
M

Mamue

Hmm, i only have a copy of the latest Visual Studio. Is there any free
alternative IDE to build VB 6 dll's ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top