Individual name/email in a global template

K

Kirsten

Any idea how I can make this work?

We have one global template (for a transmittal) on our server, yet people
want to put their individual name, phone number, and email address in the
template. No one will want to fill in their info over and over again so
they'll probably just fill in their specific info, save it to their hard
drive, and we lose the whole purpose of having templates on the server.

Any ideas how I can use VBA to automatically fill in a person's information
into a global template upon opening?
Thanks!
-Kirsten
 
C

Charles Kenyon

When you say "global template" do you perhaps mean workgroup document
template? That is a template usually maintained on a server which is used by
everyone to create a certain document, like a transmittal. A global template
is never used to create a document, it contains user interface changes like
keyboard shortcuts, macros, toolbars, and AutoText, or even custom dialog
boxes.

If it is a workgroup template and you know the user names in Word on each
computer, you can write a simple AutoNew macro that gets the username
information from Word when the document is created and uses that information
to put variable information into custom document properties which are then
displayed in the document using DOCPROPERTY fields. You can hard-code the
variable information in your template's AutoNew macro or you can save it as
document variables in the template (or in an ini file on the server) and
then reload it each time the template is used.

You could even write the template so that if it encountered a username for
which it did not have data it would ask for the data and save it back to
your template for future use.

If it is truly a global template, I guess I would like to know more about
how it is generating this transmittal without using a Workgroup template.

I've done similar things (a letterhead or other form to be used in 50
different offices) using a global template to hold the local information as
AutoText which is then inserted into the document using AutoText fields in
the document template.
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
K

Kirsten

Sorry, you are correct. It is a "workgroup document template". And I know
the users names and would like to hard-code the information into the macro.
And, yes, yes, yes, I would love to have it save a new username for future
use also. :)

So it sounds like I need to research DOCPROPERTY fields. Unfortunately, my
help menu just bit the dust. I'm using the internet to research now. I
have a document that already uses VBA and autotext so I should be good to go
there. Thanks for the start!

-Kirsten
 
C

Charles Kenyon

Go to the MVP FAQ site to start your document property research. It'll save
your hair from being torn out.
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
K

Kirsten

Wow, lots of information on the site! :) Thanks. Well, all this
information is jsut rattling around in my head and I'm not sure what to do
with it, so I'm just gonna do a quick brain-spill:

The easiest way I see to do this is autotext. I can insert autotext in the
template for each person (containing name, phone number, title, etc... )and
have the autotext Name be the person's initials. When the template is used,
an input box can appear asking for the persons initials. The correct
autotext would then be entered into the new document. (That's the easist
but I'm sure that's some pretty ugly programming.) :p

So there must be a 'cleaner' way. I'm thinking using 'application.username'
to find the authors name automatically? (My computer's running ridiculously
slow right now, so I'm having a hard time testing this.)

I'm pretty sure I don't want to hard code the information into the macro
because other people would not be able to change it. (They are
"macro-challenged" around here.) :)

Another thought I had would be a database with people's information in it:
Name, Title, Phone#, and EmailAddress. That way, someone could easily keep
that database up-to-date if new people start. A user would then go File ->
New and the template would open up, scan the application.username(?) or
prompt for user initials (?), match it to an entry in the database, and
insert Name, Title, Phone# , etc... using Fields(?) at the top of the
document.

I think I'm getting dizzy. <g> Any tips on what's the "cleanest" way to
approach this? It appears my main stumbling point is *how* to tell the
computer which name (& associated data) to insert.

Any help would be appreciated and allow me to get to sleep better. :)

Charles Kenyon typed:
 
C

Charles Kenyon

I suspect you will end up with more than one template that uses this
information once you figure out how to do it. If you are using AutoText, I
recommend putting your AutoText into a global template so that it will be
available in all of them.

I would recommend AT entry names that will not normally be typed. For
example:

Name Entry

zCKKinit CKK
zCKKname Charles Kyle Kenyon
zCKKphone (555) 123-4567
zCKKstreet 1234 Main Street, Suite 503
zCKKCSZ Anytown, MA 00000-1111

Your initial query is for three initials. These should be found at:
Application.UserInitials

Here is a sample macro to go into a global template:

Sub GetLocalInfo()
Dim tempGlobal As Template
Dim strEntryPrefix As String
Dim strName As String
Dim strStreet As String
Dim strPhone As String
Dim strCSZ As String

Set tempGlobal = Templates(ThisDocument.FullName)
strEntryPrefix = "z" & Application.UserInitials
strName = tempGlobal.AutoTextEntries(strEntryPrefix & "Name")
strStreet = tempGlobal.AutoTextEntries(strEntryPrefix & "Street")
strPhone = tempGlobal.AutoTextEntries(strEntryPrefix & "Phone")
strCSZ = tempGlobal.AutoTextEntries(strEntryPrefix & "CSZ")
MsgBox strName
MsgBox strStreet
MsgBox strCSZ
MsgBox strPhone
End Sub

It can be run from another template (once your global is properly loaded)
using:

Application.Run MacroName:= "GetLocalInfo"

This works when my user initials are "CKK" and the global template has
AutoText entries named as specified. I'll leave inserting the text where you
want it or into document properties up to you. You can find information on
inserting text at bookmarks on the MVP FAQ as well.

Final note on Global templates. You can have them on your server and have
everyone load the same template either using a shortcut or by designating
that folder as the Word Startup folder. If you do this, you'll find that you
can't edit your template when anyone has Word loaded. To get around this,
the network login script should update the template from your location to a
personal Word startup folder (on the network or on the local computer). That
way, the master global template is not locked for editing when people are
using Word.

Hope this gets you started.
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
K

Kirsten

Thanks for the info, Charles. This is invaluable. I'll need some time to
digest it now, so wish me luck! :)
 

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