Renaming a Mergefield using Delphi 6

J

J

Hi,

How do I search and rename a mergefield in word using Delphi 6? I can search
for the text in
the document and also find the field using

word.ActiveDocument.Fields.item(1).select

but how do I rename it and carry on searching through the doc to find and
rename more fields??

Thanks

J
 
C

Cindy M -WordMVP-

Hi J,
How do I search and rename a mergefield in word using Delphi 6? I can search
for the text in
the document and also find the field using

word.ActiveDocument.Fields.item(1).select

but how do I rename it and carry on searching through the doc to find and
rename more fields??
Easiest would probably be to modify the fields' .Code property. I might use

For Each fld in ActiveDocument.Fields
If fld.Type = wdFieldMergefield
'note: check the wd as I typed from memory
fld.Code = "Mergefield " & szNewName

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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