An example field code is { SET CUST_NAME \* MERGEFORMAT }. I am using C# but
a VBA example would likely get me going. The fields are in table cells if
that makes a difference. I've tried a few different things but I can't get
anything to work. Thanks in advance!

Re: Need to place text in fields in a Word 2003 template by Jay

Jay
Thu Apr 10 19:17:53 PDT 2008

On Thu, 10 Apr 2008 13:50:01 -0700, Salty Dog
<SaltyDog@discussions.microsoft.com> wrote:

>An example field code is { SET CUST_NAME \* MERGEFORMAT }. I am using C# but
>a VBA example would likely get me going. The fields are in table cells if
>that makes a difference. I've tried a few different things but I can't get
>anything to work. Thanks in advance!

Use the Add method of the Fields collection of the document. To insert your
example field at the beginning of the document, you could do this:

Sub demo()
Dim myRg As Range
Set myRg = ActiveDocument.Range
myRg.Collapse wdCollapseStart

ActiveDocument.Fields.Add Range:=myRg, _
Type:=wdFieldSet, Text:="CUST_NAME", _
PreserveFormatting:=True
End Sub

Some programmers prefer to use Type:=wdFieldEmpty and then put the entire field
code into the Text parameter. I don't think it makes a difference either way.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.