template with auto fields

I

Irena

I want to set up a template that when it is opened by a
user it prompts for info that is then places in teh header
or footer e.g. what is the documetn title, what version no
is this, who is the author. Can this be done? Is it
easy? Are their companies who will design these sorts of
templates if I pay for it?
 
G

Greg Maxey

Irena,

Yes.
Yes.
Yes.

You will need an AutoNew Macro which prompts users for
inputs to set DocProperty values and update fields. Then
put DocProperty Fields in your template header or footer.

Word already has built in Title and Author document
properties. You will need to create a custom propert
titled Version. You do this with File>Properties>Custom

Type in Version then set a type and value and click add.

Your will need to include the following in your header or
footer:

Title: { TITLE } Author: { AUTHOR } Version: {
DOCPROPERTY Version }

Note the { } field brackets are entere with CTRL+F

The AutoNew Macro code is:

Sub AutoNew()
Dim Expr1 As String
Dim Expr2 As String
Dim Expr3 As String
Dim oStory As Range

Expr1 = InputBox("Enter the Document Title:", "Title")
Expr2 = InputBox("Enter the Document Author:", "Author")
Expr3 = InputBox("Enter the Document Version:", "Version")

ActiveDocument.BuiltInDocumentProperties("Title").Value =
Expr1
ActiveDocument.BuiltInDocumentProperties("Author").Value =
Expr2
ActiveDocument.CustomDocumentProperties("Version").Value =
Expr3

For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType < wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing

End Sub

For help applying the macro see:

http://www.gmayor.com/installing_macro.htm

If you feel that I have helped you save the money that you
where willing to spend for someone to do this for you then
please donate it to your favorite charity :)
 
G

Greg Maxey

Irena,

When you set your custom VERSION document property, it
would probably be better to use TEXT as the type vice a
number. Just type Version in the Name window, select the
TEXT type and then put an empty space in the value field
and click add.

I discovered if you set NUMBER as the type and then the
user types an alphanumeric version a run time error is
generated when the AutoNew macro fires. With TEXT type
the user and type a number or an alphanumeric value.
 
Top