How to call a Word VBA subroutine from a Global Template?

P

Paul J

I have created some Word templates which contain several VBA macros
(sub/function) in common.

In order to make maintenance easier I have created a Global Template and
moved the VBA code in from the original templates.

Having added the Global Template to the current Word session (using Tools,
Templates and Add-Ins) I am now ready to call these subroutines from the
original templates.

I have spent nearly 10 hours researching this question today, so it is with
some humility that I must now ask:
- how, within a VBA subroutine, do you register the availability of the
Global Templates?
- how do you then call a subroutine from a Global Template?

Your help would be very much appreciated.
Paul J
 
S

Shauna Kelly

Hi Paul
- how, within a VBA subroutine, do you register the availability of the
Global Templates?

Open the global template. In the VBE, in the Project Explorer, right-click
your file (it probably says "Template project") and give it a useful name.
Save. Close.

Open the template. In the VBE, use Tools > References to create a reference
to the add-in. It will be listed under the name you gave it.
- how do you then call a subroutine from a Global Template?
Call the function as, eg, x=MyAddin.MyFunction
I have spent nearly 10 hours researching this question today,
Next time you have a problem like this, search the google groups archive at
http://groups.google.com.au/advanced_search?hl=en
A search for 'call subroutine from Global Template' with the group set to
microsoft.public.word.* gets your answer in a flash.

Hope this helps.

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

Paul J

Please accept my gratefull thanks, Shauna.

Shauna Kelly said:
Hi Paul


Open the global template. In the VBE, in the Project Explorer, right-click
your file (it probably says "Template project") and give it a useful name.
Save. Close.

Open the template. In the VBE, use Tools > References to create a reference
to the add-in. It will be listed under the name you gave it.

Call the function as, eg, x=MyAddin.MyFunction

Next time you have a problem like this, search the google groups archive at
http://groups.google.com.au/advanced_search?hl=en
A search for 'call subroutine from Global Template' with the group set to
microsoft.public.word.* gets your answer in a flash.

Hope this helps.

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

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