Opinions From MVPs regarding Startup Folder Location

A

Anne P.

Hi to all the wonderful MVPs out there. I have a question that I would like
to pose to you all regarding the "ideal" location for Word's Startup folder
for storing "Global Templates" or "Add-ins". I just read Dave Rado's
article on the MVPS.org website regarding templates. It appears from that
article that the "ideal" location for these types of templates is the
default one set by Microsoft which is: C:\Documents and
Settings\username\Application Data\Microsoft\Word\Startup.

I am creating a set of templates and macros for a NYC law firm. This is how
I have my system setup, however, I have encountered numerous problems doing
it this way. The main problem that I am encountering is that I cannot set a
reference to the "Global templates" in the VBE (Tools, References), as those
templates will be in a different location on each user's machine. I have
numerous macros that are needed by more than one template, so I stored them
in my global template (SKGlobal), but encountered a problem calling those
macros from the other templates. After much searching on Google and the
various Word message boards and posting my own messages on the message
board, I finally got the answer that I needed to do the following:
Application.Run "globaltemplate.modulename.macroname" to make them run.

Now I am encountering another problem which I have not been able to find an
answer to: how to call Functions that are stored in a global template. I
am using a Function called "StringtoArray" to separate a long string into
elements of an Array. Example: I have the following string (stored as an
AutoText entry in a global template):

Anne Pontillo|Partner|ALP|jap|NY|40566|(201)
476-1119|[email protected]|Yes



From the letter template, when this entry is chosen, I need to separate it
into an array using the "|" as the point to separate the elements. I need
to pass three arguments to the function to make it work: mstrUserInfo (the
string mentioned above), astrUserInfo() (the name of the array variable
declared in the project), and "|" (the character to use as the delimiter).
My problem is that this same function needs to be used in numerous
templates. Since I have not been able to find any information on how to
call the function from the global template when there is no reference set to
that global template, I have to copy these functions into every template
that needs to use that function. For example, from a recent posting if mine
on this forum, I am using an article from the MVPS website to "disable" the
X button on a userform. This procedure has two constants, 5 functions, and
1 variable that are declared first, and then approximately 21 lines of code
(including the comments) that needs to be placed in the Userform_Initialize
event. If I have 15 templates, I have to copy all of that code into each
and every template.



At last count, I have an additional 10-15 functions that have to be placed
in each template. All of this would be so much easier if I could place the
functions in the Global template (SKGlobal) and set a reference to it from
my other templates, or call the functions from my other templates.



So my question is this: is the Documents and Settings location the best one
to use for a startup location and, if so, how can I reduce the bloat on my
other templates by keeping my functions in the global template? I just did
an experiment with my letter template. The file size of the template was 97
KB. I deleted the functions that were stored there and the file size was
reduced to 63 KB. Therefore, each of my templates has an extra 34 KB
because the functions have to be stored in each template.



I would really appreciate any comments or suggestions regarding best
practices in setting this environment up, or advice on how to make it work
as is without all the extra work.



Anne P.
 
J

Jonathan West

Hi Anne

Anne P. said:
Hi to all the wonderful MVPs out there. I have a question that I would
like to pose to you all regarding the "ideal" location for Word's Startup
folder for storing "Global Templates" or "Add-ins". I just read Dave
Rado's article on the MVPS.org website regarding templates. It appears
from that article that the "ideal" location for these types of templates
is the default one set by Microsoft which is: C:\Documents and
Settings\username\Application Data\Microsoft\Word\Startup.

That is the default location. You can change it by going to Tools, Options,
clicking on the File Locations tab, selecting the Startup folder and
clicking Modify.

However, if your computers have multiple users each of whom logs on under
their own name, this change would need to be made for each user. Its
probably easier to leave it where it is.
I am creating a set of templates and macros for a NYC law firm. This is
how I have my system setup, however, I have encountered numerous problems
doing it this way. The main problem that I am encountering is that I
cannot set a reference to the "Global templates" in the VBE (Tools,
References), as those templates will be in a different location on each
user's machine. I have numerous macros that are needed by more than one
template, so I stored them in my global template (SKGlobal), but
encountered a problem calling those macros from the other templates.
After much searching on Google and the various Word message boards and
posting my own messages on the message board, I finally got the answer
that I needed to do the following: Application.Run
"globaltemplate.modulename.macroname" to make them run.

Now I am encountering another problem which I have not been able to find
an answer to: how to call Functions that are stored in a global template.
I am using a Function called "StringtoArray" to separate a long string
into elements of an Array. Example: I have the following string (stored
as an AutoText entry in a global template):

Anne Pontillo|Partner|ALP|jap|NY|40566|(201)
476-1119|[email protected]|Yes

You can't call Functions using Application.Run. What you can do instead is
convert the Function to a Sub, and have one of the parameters of the Sub
carry the return value. I'll give you a trivial example to demonstrate the
concept.

In a single template, you might have a simply function like this

FunctionAddTwoNumbers(a as Long, b as Long) as Long
sum = a + b
End Sub


You would call it from another routine in the template like this

Sub TestAdding()
Dim x as Long
Dim y as Long
Dim total as Long
x = 1
y = 2
total = AddTwoNumbers(x, y)
MsgBox total
End Sub

With a global template, you have the convert the Function to a sub, like
this

Sub AddTwoNumbers(a as Long, b as Long, sum as Long)
sum = a + b
End Sub


You can call it from the another template like this

Sub TestAdding()
Dim x as Long
Dim y as Long
Dim total as Long
x = 1
y = 2
Application.Run "AddTwoNumbers", x, y, total
MsgBox total
End Sub


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
J

Jean-Guy Marcil

Jonathan West was telling us:
Jonathan West nous racontait que :
Hi Anne

(...)

You can't call Functions using Application.Run. What you can do
instead is convert the Function to a Sub, and have one of the
parameters of the Sub carry the return value. I'll give you a trivial
example to demonstrate the concept.

In a single template, you might have a simply function like this

FunctionAddTwoNumbers(a as Long, b as Long) as Long
sum = a + b
End Sub


You would call it from another routine in the template like this

Sub TestAdding()
Dim x as Long
Dim y as Long
Dim total as Long
x = 1
y = 2
total = AddTwoNumbers(x, y)
MsgBox total
End Sub

Oops! I think your fingers were faster than your eyes! ;-)

Function AddTwoNumbers(a As Long, b As Long) As Long
AddTwoNumbers = a + b
End Function


Sub TestAdding()
Dim x As Long
Dim y As Long
Dim total As Long
x = 1
y = 2
total = AddTwoNumbers(x, y)
MsgBox total
End Sub

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
C

Chuck

Hi Anne

I'm not a credentialled MVP but I hope you won't mind my sharing my solution
for the same situation you're in.

I have a global template that is downloaded to a specified folder on the
user's local drive, that location being the same on all local stations (if
the folder doesn't exist, the login script creates it). This gets around the
problem of each user's startup folder being unique. An AutoExec macro in
Normal.dot ensures that any necessary add ins are loaded from that standard
local location. (If you don't want to put an AutoExec macro in Normal.dot you
can put it in some other Startup add-in - Normal.dot is appropriate for the
circumstances I'm working with.)

I give the code in my global template a unique Project Name in the VBE (eg
"XYZCode"). To give the project a unique name, right click on the project in
the VBE and choose properties then give it a name.

In the "client" document/template that needs to call the global template's
code, I create a reference to the global template located on my local
machine. Because that folder is the same on all machines, the reference will
work for all users.

In the client code I refer to the global code by specifying the reference to
the project name first, followed by a period - the macros in the global code
are automatically listed. For instance, the following will return the
function fncMyFunction and pass the string "string parameter":

XYZCode.fncMyFunction "string parameter"

The above works fine for us. HTH...
 
A

Anne P.

Jonathan,

Thanks for your comments. I have few questions on this (noted below under
your responses).

Thanks,
Anne P.
Jonathan West said:
Hi Anne



That is the default location. You can change it by going to Tools,
Options, clicking on the File Locations tab, selecting the Startup folder
and clicking Modify.

However, if your computers have multiple users each of whom logs on under
their own name, this change would need to be made for each user. Its
probably easier to leave it where it is.

I understand that the Documents and Settings thing is the default location.
The firm I am doing the templates for is currently using Office 97 and
Windows NT 4.0 (where C:\Program Files\Microsoft Office\Office\Startup or
something similar is being used as the startup directory). This is great
because if a new template or macro is needed a reference to the Global
template can easily be set.

The firm is moving to Office 2003 with Windows XP in the very near future,
but none of the machines have been set up yet. I am creating their
templates and macros now. So, if the initial machine (from which all other
machines are to be cloned), uses C:\Program Files\Microsoft
Office\Office\Startup as the Startup directory (In Tools, Options, File
Locations), is that such a bad thing? Since it would make my work so much
easier (I can then set a reference to the Global template from any new
template I create), can anyone give me a good reason why I should use the
Doucments and Settings location as opposed to the Program Files location?
You can't call Functions using Application.Run. What you can do instead is
convert the Function to a Sub, and have one of the parameters of the Sub
carry the return value. I'll give you a trivial example to demonstrate the
concept.

In a single template, you might have a simply function like this

FunctionAddTwoNumbers(a as Long, b as Long) as Long
sum = a + b
End Sub


You would call it from another routine in the template like this

Sub TestAdding()
Dim x as Long
Dim y as Long
Dim total as Long
x = 1
y = 2
total = AddTwoNumbers(x, y)
MsgBox total
End Sub

With a global template, you have the convert the Function to a sub, like
this

Sub AddTwoNumbers(a as Long, b as Long, sum as Long)
sum = a + b
End Sub


You can call it from the another template like this

Sub TestAdding()
Dim x as Long
Dim y as Long
Dim total as Long
x = 1
y = 2
Application.Run "AddTwoNumbers", x, y, total
MsgBox total
End Sub
Jonathan, while your idea sounds good on paper, several of the functions I
am using will call a second function before it is complete. I think that
getting into converting all these functions to subs is a bit above what I
want to get into right now.
 
J

Jonathan West

Anne P. said:
Jonathan,
I understand that the Documents and Settings thing is the default
location. The firm I am doing the templates for is currently using Office
97 and Windows NT 4.0 (where C:\Program Files\Microsoft
Office\Office\Startup or something similar is being used as the startup
directory). This is great because if a new template or macro is needed a
reference to the Global template can easily be set.

The firm is moving to Office 2003 with Windows XP in the very near future,
but none of the machines have been set up yet. I am creating their
templates and macros now. So, if the initial machine (from which all
other machines are to be cloned), uses C:\Program Files\Microsoft
Office\Office\Startup as the Startup directory (In Tools, Options, File
Locations), is that such a bad thing? Since it would make my work so much
easier (I can then set a reference to the Global template from any new
template I create), can anyone give me a good reason why I should use the
Doucments and Settings location as opposed to the Program Files location?

Yes, there is a good reason to use the Documents and Settings location.
Templates in that location (unlike in the Program Files folder) are regarded
by Word as "installed templates" and can be set as more trusted.

If you are moving towards Office 2003, you need to consider carefully the
fact that the default security setting is "High" which means that VBA code
is not run at all unless the templates are sgned with a digital certificate.
You will need to research this issue and decide how tou are going to manage
certificates, security and deployment in an integrated way.
Jonathan, while your idea sounds good on paper, several of the functions I
am using will call a second function before it is complete. I think that
getting into converting all these functions to subs is a bit above what I
want to get into right now.

If the secondary functions are only called from routines in the same
template, then they need not be converted. If you go this route, you need
only convert those functions which you want to call directly from other
templates.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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