Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
In order to speed up setup of a word doc that is a long contract, can I use
find replace to insert the mergefield I want into the document. Eg. Mergfield={ CMDHB } replacing text in doc XDHB Hope this makes sense? or is there another way I can do this (I am not very VB literate) Thanks |
#2
![]() |
|||
|
|||
![]()
If there is a consistent pattern to what you want to replace - e,g, all text
that is to be replaced with a merge field begins with an uppercase X and the letters in the text are all in uppercase and the corresponding mergefield has the X replaced by CM, then it should be possible using code such as the following: Dim drange As Range, dfield As String Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="X[A-X]{1,}", MatchWildcards:=True, Wrap:=wdFindContinue, Forward:=True) = True Set drange = Selection.Range dfield = "CM" & Mid(drange, 2) ActiveDocument.Fields.Add Range:=drange, Type:=wdFieldMergeField, Text:=dfield Loop 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 "Chris" wrote in message ... In order to speed up setup of a word doc that is a long contract, can I use find replace to insert the mergefield I want into the document. Eg. Mergfield={ CMDHB } replacing text in doc XDHB Hope this makes sense? or is there another way I can do this (I am not very VB literate) Thanks |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is there a way to find and replace a text string with a field nam. | Microsoft Word Help | |||
Find and Replace GREEK symbols in XP, 2K & 97 | Microsoft Word Help | |||
Problem with function "Find and Replace" in Word. | Microsoft Word Help | |||
Find and Replace anomaly | Microsoft Word Help | |||
find and replace symbols | New Users |