Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / April 2004

Tip: Looking for answers? Try searching our database.

Replacing Merge Fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dominic Godin - 23 Apr 2004 10:17 GMT
Hi,

I am writing some software that updates clients' data to the new version of
our product.  Part of this data contains many thousand Word templates with
MailMergeDataFields.  These fields need to be replaced with the new
corresponding fields.

I can use the:

WordDoc.MailMerge.DataSource.DataFields.Item(index).Name

to get all the merge fields held within a document but this field is read-
only so I can't update it.

I have tried using the Find.Execute to search and replace these fields but
this doesn't work either.  Any body no how this can be done?

Thanks

Dominic Godin
Dominic Godin - 23 Apr 2004 15:12 GMT
Dominic Godin <nospam@plz> wrote in
Don't worry worked it out :).

news:Xns94D468B07D7Dnospamplz@207.46.248.16:

> Hi,
>
[quoted text clipped - 16 lines]
>
> Dominic Godin
Doug Robbins - Word MVP - 24 Apr 2004 04:43 GMT
Use the following to change the mergefield names in the mailmerge main
documents:

Dim amf As Field, fcode As Range, i As Integer, j As Integer
For Each amf In ActiveDocument.Fields
   Set fcode = amf.Code
   i = InStr(fcode, Chr(34))
   j = InStr(Mid(fcode, i + 1), Chr(34))
   fcode.Start = fcode.Start + i
   fcode.End = fcode.Start + j - 1
   Select Case fcode
   Case "Fname"
       fcode.Text = "FirstName"
   Case "Lname"
       fcode.Text = "LastName"
   End Select
Next amf
ActiveDocument.Fields.Update

Signature

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested.  Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP

> Hi,
>
[quoted text clipped - 16 lines]
>
> Dominic Godin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.