Global variable VBA

K

kgribbe

Hey,

Our organisation is currently looking for a way to manage/edit our macro
system easier

Currently all templates/macros are saved in a folder called "dot2008" the
autoexec macro opens a menu.dotm by "Documents.Open FileName:=Installdir &
"\menu.dotm", ReadOnly:=True" which is already a dynamic URL from the
"dot2008" folder so only has to been changed on 1 postion if it ever changed
instead of in all the modules.

However our biggest problem now is to find a way to transfer variables from
1 project to another in word(currently we do this by writing the variables
into a .txt file and then opening that text file in another project to get
the variables out of it)

for example:
WordBasic.Filenew Newtemplate:=0, Template:="templateletter3.dotm"

in menu.dotm there is a procedure that open a template letter template which
also has macros that have to use variables which got used in menu.dotm(so
currently it opens the txt file where menu.dotm has saved the variables to
inorder to use the same)

The problem however is that we have to add a lot of new modules/projects in
our organistion for the new services, which means we currently have to change
every single macro for it to be able to read the new variables from the .txt
file

So any ideas on how we can transfer variables from 1 project to another? or
from 1 document to another
 
J

Jean-Guy Marcil

kgribbe said:
Hey,

Our organisation is currently looking for a way to manage/edit our macro
system easier

Currently all templates/macros are saved in a folder called "dot2008" the
autoexec macro opens a menu.dotm by "Documents.Open FileName:=Installdir &
"\menu.dotm", ReadOnly:=True" which is already a dynamic URL from the
"dot2008" folder so only has to been changed on 1 postion if it ever changed
instead of in all the modules.

However our biggest problem now is to find a way to transfer variables from
1 project to another in word(currently we do this by writing the variables
into a .txt file and then opening that text file in another project to get
the variables out of it)

for example:
WordBasic.Filenew Newtemplate:=0, Template:="templateletter3.dotm"

in menu.dotm there is a procedure that open a template letter template which
also has macros that have to use variables which got used in menu.dotm(so
currently it opens the txt file where menu.dotm has saved the variables to
inorder to use the same)

The problem however is that we have to add a lot of new modules/projects in
our organistion for the new services, which means we currently have to change
every single macro for it to be able to read the new variables from the .txt
file

So any ideas on how we can transfer variables from 1 project to another? or
from 1 document to another

Why don't you use an Optional Parameters in the macro that are called which
used the variable? SO the calling macroonly need to supply the variable as a
parmeter.

Sub myMacro1()

code
code
Call myMacro2 "Some Text"

End Sub

Sun myMacro2(Optional strText As String)

Selection.TypeText strText
code
code
etc.
End sub
 

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