Is there a way to find and replace a text string with a field nam.

G

Guest

I would like to replace a text string with a field name throughout the entire
document. The find/replace does not allow me to insert a field name. Is
there another way?
 
D

Doug Robbins

You would need to use a bit of VBA code for this:

Dim myrange as Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
While .Execute(FindText:="some string", MatchWildcards:=False,
Wrap:=wdFindStop, Forward:=True) = True
Set myrange = Selection.Range
Code to add the field using ActiveDocument.Fields.Add myrange, etc
Wend
End With


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

Graham Mayor

Type the field in the document, copy it to the clipboard, then replace your
text with the content of the clipboard (^c).

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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