Reply
 
Thread Tools Display Modes
  #1   Report Post  
Chris
 
Posts: n/a
Default Is it possible to use find replace for Merge Field data

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   Report Post  
Doug Robbins
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to find and replace a text string with a field nam. Jeff Janoski Microsoft Word Help 2 May 26th 05 05:47 AM
Find and Replace GREEK symbols in XP, 2K & 97 Jazz Microsoft Word Help 3 April 8th 05 08:13 PM
Problem with function "Find and Replace" in Word. Pat Microsoft Word Help 3 March 16th 05 01:04 PM
Find and Replace anomaly BruceM Microsoft Word Help 7 January 18th 05 05:47 PM
find and replace symbols Tewodaj New Users 8 January 11th 05 02:22 AM


All times are GMT +1. The time now is 01:34 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"