Help with FIELD CODES: DOCVARIABLE!!!

G

Guest

I am creating a template for other users. I would like a portion of the
footer to automatically be the same as the "Project Title" that the user will
assign. It seems like I might be able to use the "DocVariable" Field Code to
do this, but I don't understand how to assign/create the variables. Can
anyone help?

Thanks.
 
J

Jay Freedman

Wendy said:
I am creating a template for other users. I would like a portion of
the footer to automatically be the same as the "Project Title" that
the user will assign. It seems like I might be able to use the
"DocVariable" Field Code to do this, but I don't understand how to
assign/create the variables. Can anyone help?

Thanks.

If the information is being entered on the Custom tab of the File >
Properties dialog, then you need to use a DocProperty field instead of a
DocVariable field.

Document variables can be created and modified only through macro code.
Document properties -- both built-in and custom -- can be managed in the
Properties dialog or by code.
 
D

Doug Robbins

How is the user going to assign the "Project Title"

If it's via a control named txtProjectTitle on a Userform, in the command
button code in the form, you would use

With ActiveDocument
.Variables("varProjectTitle").Value = txtProjectTitle
.Range.Fields.Update
For i = 1 To .Sections.Count
.Sections(i).Footers(wdHeaderFooterFirstPage).Range.Fields.Update
.Sections(i).Footers(wdHeaderFooterPrimary).Range.Fields.Update
Next i
End With

Then you would have a {DOCVARIABLE "varProjectTitle"} field wherever in the
document you wanted the Project Title to appear.

--
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