Using Word 2003 with XP Pro. I've created a template with
a few fields near the top. In the Text Form Field
Options Dialog Box on the letterhead (first Page) I
placed a field with Default LastName, First Middle. I
named it NameLFM with Fillin enabled and Calculate on
Exit checked. In the header of page 2 I placed { REF
NameLFM } for this to appear on all subsequent pages. (I
changed Page Setup)
I saved the template and open as a document. I fill in
dummy information in all the fields and view in Page
Preview. On screen it says Reference Not found twice in
the page 2 header. And when I go to view the header in
the document, there is no place holder or other
designation that the REF field is/was there. When I open
the template up to solve the issue, the { REF NameLFM }
is gone.
If I lock the form, I can't fillin other areas of text in
my template.
Also, in a calculated Age field =(Date of Visit -
DOV)/365 elsewhere on the form, the calculated option
only allows number results for intergers or numbers with
2 decimal places. I would like an Age with a single
decimal i.e. Age = 15.5 not 15.53. The option is not
given.
Thanks,
Phil
Formfields will only work if the section in which they are located is
protected for forms. If you want to be able to enter text elsewhere in the
document, you will need to divide the document into sections so that you can
protect the section containing the formfields and leave the balance of the
document unprotected.
See "Please Fill Out This Form"
Part 1: Create professional looking forms in Word
http://www.computorcompanion.com/LPMArticle.asp?ID=22
Part 2: Adding Automation to your Word forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=46
Part 3: Learn more VBA (macros) to automate your forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=119
Part 4: Use custom dialog boxes in your Word forms
http://www.computorcompanion.com/LPMArticle.asp?ID=127
Part 5: Connect your AutoForm to a database to save input time and keep
better records!
http://www.computorcompanion.com/LPMArticle.asp?ID=136
Or you might be better of to use a userform.
See the article "How to create a Userform" at:
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm
For your decimal formatting problem, see "Formatting Word fields with
switches" on fellow MVP Graham Mayor's website at
http://www.gmayor.com/formatting_word_fields.htm

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Using Word 2003 with XP Pro. I've created a template with
> a few fields near the top. In the Text Form Field
[quoted text clipped - 26 lines]
> Thanks,
> Phil
philr - 02 Oct 2004 16:03 GMT
Thanks Doug, Excellent answers. I glanced over the information you just
provided but I wanted to ask a followup that doesn't seem to be addresed.
If I create a UserForm or similar, I was thinking the odeal solution for me
would be to also use select information from the fields to create the file
name. IOW, If I create couple fields like patientName, patientID, clinicDate
for input into the document fields can I use these same fields to identify
and save the file to say
smith mary 1234567890 04-10-02.doc
Is there a special name for this type of variable pass through. (I'm familar
with programming but not VB or VBA.)
> Formfields will only work if the section in which they are located is
> protected for forms. If you want to be able to enter text elsewhere in the
[quoted text clipped - 59 lines]
> > Thanks,
> > Phil
Doug Robbins - 02 Oct 2004 22:56 GMT
Use the .Result property of a formfield to obtain the data that is entered
into it
With ActiveDocument
.SaveAs .Formfields("PatientName").Result &
.Formfields("PatientID").Result & .Formfields("ClinicDate").Result
End With

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Thanks Doug, Excellent answers. I glanced over the information you just
> provided but I wanted to ask a followup that doesn't seem to be addresed.
[quoted text clipped - 79 lines]
>> > Thanks,
>> > Phil
philr - 06 Oct 2004 21:13 GMT
Now that I got the bookmarks and UserForm to work can/should I consider using
form fields instead if I want to create the file name from the data input
into the form fields (bookmarks)?
I like the autonew box seeking information up front and would like to use
much of this same data to create the file name when I go to save the document.
I do have the bookmarks currently sectioned off. If I decide to use form
fields, how do I protect the fields and still enter information in the other
sections of the template?
Phil
> Use the .Result property of a formfield to obtain the data that is entered
> into it
[quoted text clipped - 87 lines]
> >> > Thanks,
> >> > Phil
Doug Robbins - 07 Oct 2004 01:40 GMT
I would dump the formfields altogether. You can build the filename from the
data entered into the userform.
For example if you had a textbox on the userform named txtName and you
wanted to save the document with that name, you would include the following
in the code associated with the command button click event
ActiveDocument.SaveAs txtName

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Now that I got the bookmarks and UserForm to work can/should I consider
> using
[quoted text clipped - 112 lines]
>> >> > Thanks,
>> >> > Phil
philr - 05 Oct 2004 20:01 GMT
Thx Doug,
I took your advice and created a UserForm. I created 5 bookmarks and
entered the code as on the reference you supplied.
When I add the bookmark Word supplies a grey area with little circles. When
I lauch a document from the templete the document gets the information as
supplied but it pushes the little grey box to the right. I tried turning off
Tools>Option>View>Bookmark off and turned off the dispalyparagraph, but they
are still there.
I have the same problem when I { REF NameLFM } in the header of the next
page.
A fifth box was was actually a calculation to acquire age when subtracting
two dates input via the VB Dialog Box. The document shows both dates but the
age shows 0.0. ex. =(DOV-DOB)/365 (I assume it works like Excel.)
Also, I would like to format the bookmark to make the results bold both in
the body and the header.
> Formfields will only work if the section in which they are located is
> protected for forms. If you want to be able to enter text elsewhere in the
[quoted text clipped - 59 lines]
> > Thanks,
> > Phil
Doug Robbins - 06 Oct 2004 01:02 GMT
The grey area with little circles is a formfield (probably left over from
your previous method)
When you insert the bookmarks in the template, make sure that you have a
space selected so that when the display of bookmarks is turned on, they look
like [], not like |. Then when the data is inserted before the range of the
bookmark, it will actually be inserted inside the [] like [this]. Then your
cross-references to the text of the bookmark will work. You will however
need to include code to update the fields in the header of the document
Dim i as Long
For i = 1 to ActiveDocument.Sections.Counte
ActiveDocument.Sections(i).Headers(wdHeaderFooterPrimary).Range.Fields.Update
Next i
It's not clear where you are doing the calculation. If you are actually
doing it in the document using a formula field, you would need an
ActiveDocument.Fields.Update command to update the fields in the body of the
document itself.
I would do the calculation in the code behind the userform and insert the
result into a bookmark just like the other data.
To get the data in the bookmark to be bold, select the bookmark in the
template and apply that formatting to it. For the cross reference field, at
a \*charformat switch inside the closing field delimiter } and then apply
the desired formatting to the R of REF

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Thx Doug,
> I took your advice and created a UserForm. I created 5 bookmarks and
[quoted text clipped - 86 lines]
>> > Thanks,
>> > Phil
philr - 06 Oct 2004 21:13 GMT
Regarding Age calc
If I have bookmarks defining say today's date and Date of Birth and these
are being entered into the user form as text fields. With Form fields, they
could be given a bookmark name and I could check calculate. Somehow I need
to define these as Dates then have to perform calculations on them. The Text
Box control doesn't do this.
Or is it better to create these as fields, lock them in a section and then
do calculations.
Phil
> The grey area with little circles is a formfield (probably left over from
> your previous method)
[quoted text clipped - 23 lines]
> a \*charformat switch inside the closing field delimiter } and then apply
> the desired formatting to the R of REF
Doug Robbins - 07 Oct 2004 01:54 GMT
I assume that on the userform you have a textbox into which the Date of
Birth is entered and let's assume that it is named txtDOB. Then you can get
the age by using the DateDiff function
Dim DOB As Date
DOB = CDate(txtDOB)
MsgBox "The patient's age is " & DateDiff("yyyy", DOB, Now)
or to insert it into a bookmark in the document named age, use
ActiveDocument.Bookmarks("age").Range.InsertBefore DateDiff("yyyy", DOB,
Now)

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Regarding Age calc
>
[quoted text clipped - 45 lines]
>> a \*charformat switch inside the closing field delimiter } and then apply
>> the desired formatting to the R of REF