deploying word templates

A

Ales

Hello!
I want to deploy Word templates to co-workers. There are
two problems:
1. In the footer of these templates is co-worker unique ID
(a number between 0 and 999)
2. The Author of document (File/Properties/Summary/Author)
They have to change these two parameters for every template
that I send them - they have to open each template and
change ID and author.
Is there any way to make whole procedure fully automatized?
Thanks!
 
S

Shauna Kelly

Hi Ales

The first problem is the more complex to solve. Here are two possible
solutions, both of which require some VBA.

First possible solution. Create a custom property called CoWorkerID. In
the footer, insert a { DOCPROPERTY CoWorkerID } field (you must do
ctrl-F9 to create the brackets; you can't type them by hand).

In the template you distribute, set the document property to = -1 (ie,
an invalid value). In the Document_New() event (which runs every time a
user creates a new document from the template):
- interrogate that custom property value

- if it = -1 then this value is not valid and you need to get a
valid value from the user, so

- pop up an input box asking the user for their ID number
- do some basic error checking on the user's input
- save the ID that the user gave you in the custom property
value in this document
- save the ID that the user gave you in the custom property
value *in the template* and save the template to avoid this
process
next time

- else the user has been here before and the template has a valid
user ID number, so
- quit this routine
- endif

Variant on the first solution: use a document variable in the template
instead of a custom property. The advantage of using the custom property
is that if a worker's coworker ID changes, and future documents must
therefore use a different ID, the user can open the template and change
the value manually. If it's stored in a document variable, you'll have
to write a little routine to enable the user to do that.

Second possible solution. Decide on a spot on a hard disk to store a
little file (or, save it as a registry setting, but I'm not experienced
in doing that). The file is going to store the ID number. In the
Document_New() event, look for that file. If you find it, use the number
in it as the ID number. If you don't find it, ask the user for a value
and save that value in the little file. When you have a valid value, use
VBA to add the text to the footer. Don't use a Word document to save
this number (the file will be too big and cumbersome). Use an
old-fashioned plain text file.

Now your second, and much easier, problem. In the template, leave the
File > Properties > Summary > Author field blank. When a user creates a
new document from the template, Word will automatically insert the
user's name as the Author of the document. Word picks up this
information from Tools > Options > User Information, so make sure that
each user has the right information stored there.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
Melbourne, Australia
 
A

Ales

Thank you very much! I think I could make this by myself (I
am beginner in VB(A)).
BR,

Ales
 

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