variable with scope across templates

K

kbaxreno

I have a large Word project with many templates loading in and out. Is there
a way to create a variable that will be available in more than the template
is was created in? Can I use a class? or maybe include a dll? If the
solution is use a dll then a link to dll creation help would be great.

Right now all our repetitive variable values are stored in a db and every
time a template loads the values are re-read.

Thanks
Ken
 
S

Steve Rindsberg

I have a large Word project with many templates loading in and out. Is there
a way to create a variable that will be available in more than the template
is was created in? Can I use a class? or maybe include a dll? If the
solution is use a dll then a link to dll creation help would be great.

Use the registry?
 
S

Stefano

You can create an add-in, and put all the macros and the global
variables in the add-in.
It's usually better than putting macros in the template.

Cons: you need to install the add-in in all the computers that will
need to use the macros (because they are not distributed with the
files saved from the template)
Pros: the files saved from the template will not have macros, that
makes them safer and lighter, and... you will be able to use the
global variables.

Stefano
 
C

Colbert Zhou [MSFT]

Hello Ken,

I think Stefano's comment has hit the point. In order to create and use a
global variable, we need,

1.Create an template addin, and from any documents, as long as the addin is
loaded, then we can consume that variable.

2.Store the variable to Normal.dot template. This template's data should be
accessiable from whatever document.

You can refer to,
http://msdn.microsoft.com/en-us/library/aa189712(office.10).aspx
http://word.mvps.org/FAQs/MacrosVBA/DocumentEvents.htm


Best regards,
Ji Zhou
Microsoft Online Community Support
 
C

Colbert Zhou [MSFT]

I mean either of the above two patterns

Colbert Zhou said:
Hello Ken,

I think Stefano's comment has hit the point. In order to create and use a
global variable, we need,

1.Create an template addin, and from any documents, as long as the addin is
loaded, then we can consume that variable.

2.Store the variable to Normal.dot template. This template's data should be
accessiable from whatever document.

You can refer to,
http://msdn.microsoft.com/en-us/library/aa189712(office.10).aspx
http://word.mvps.org/FAQs/MacrosVBA/DocumentEvents.htm


Best regards,
Ji Zhou
Microsoft Online Community Support
 

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