Personalize templates

S

Seppe

Hi,

i want to use templates for my company.
I want all users to have the same template. It seemed to me that the best
option would be to have the templates on the server so that i can update them
there and everyone would be using the updated version automaticly.
I tried to figure out how every user can have his own name in that template.
I tried to create an xml file where the template would grasp personal
information from but didn't succeed.
Is this the good way to go? Does somebody have a better idea? Is there
somewhere on the web a nice document that describes this type of problem?

Thanks in advance.
 
S

Seppe

Thanks Doug,

I already read your article but it does noet explain how to personalize
those templates?

The template should fill in my name, phone, title when i open it, but when a
colleague opens that file it should display his information.

Any hints to accomplish this?
 
D

Doug Robbins - Word MVP

If you create a macro named autonew() in the template as follows and in the
template, you insert a { DOCVARIABLE User } field whereever you want the
User's name to appear, and likewise { DOCVARIABLE Title } and { DOCVARIABLE
Phone } fields, then when a new document is created from the template, it
will check to see if the User's name has already been entered via this macro
and if it matches the user name that is set up under Word's Options User
Name, the info will be inserted into those DOCVARIABLE fields. If the name
does not match, or not all of the information has been entered, then a
series of Input Boxes will be displayed asking the user to enter the
necessary information. That would only have to be done once.

When setting up the DOCVARIABLE fields, it is necessary to use Ctrl+F9 to
insert each pair of field delimiters { } and you use Alt+F9 to toggle off
their display.

Sub autonew()
Dim User As String, Title As String, Phone As String
User = System.PrivateProfileString("c:\UserDetails.txt", "UserDetails",
"UserName")
If User <> Application.UserName Then
User = InputBox("Please Enter your name.", "User Name")
Title = InputBox("Please Enter your title.", "Title")
Phone = InputBox("Please Enter your phone number.", "Phone")
ElseIf System.PrivateProfileString("c:\UserDetails.txt", "UserDetails",
"Title") = "" Then
Title = InputBox("Please Enter your title.", "Title")
Phone = InputBox("Please Enter your phone number.", "Phone")
Else
Title = System.PrivateProfileString("c:\UserDetails.txt", "UserDetails",
"Title")
Phone = System.PrivateProfileString("c:\UserDetails.txt", "UserDetails",
"Phone")
End If
System.PrivateProfileString("c:\UserDetails.txt", "UserDetails", "UserName")
= User
System.PrivateProfileString("c:\UserDetails.txt", "UserDetails", "Title") =
Title
System.PrivateProfileString("c:\UserDetails.txt", "UserDetails", "Phone") =
Phone
With ActiveDocument
.Variables("User").Value = User
.Variables("Title").Value = Title
.Variables("Phone").Value = Phone
.Range.Fields.Update
End With
End Sub

Instead of the series of InputBoxes, it would also be possible to display a
userform to collect the information.

See the article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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