Hi Doug,
I have decided to scrap the "change all documents at one time" idea and
decided to concentrate on the Find a merge field in the current document and
replace with a different field name. Could you lead me in the right
direction?
Here is what I have learned:
1. Must do Alt + F9 to display the field code prior to trying to "find" the
code.
2. the "^d" (field) option *doesn't* work in find and replace like it
should.
3. the "^d" (field) even if it did work isn't available in the replace
options.
The below code does "find" the text if it is in a field and replaces it.
How do I set the .Text = (some number to go through)
In other words I have an excel spreadsheet that has every field number 1- 60
in the first column, in the next I list the Access database's Field Name for
the Merge field. I want to say Find field 1 and replace with the text in
column 2. Increasing the Field number by one for each pass.
OR
Is it easier to code what each field text represents each number in VBA.
Kinda like a Select Case?? Or is this only for userforms?
i = 1
Select Case i
case 1: "Decedents_LName"
case 2: "Decedents_FName" ' and here i might want to make it \* Upper for
formatting
Sub FindField()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Customer_phone_no" ' this field will vary and will be a
number
.Replacement.Text = "My_Phone_no"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
End Sub
Thanks for you help!
Kerri
P.S. When you say: "Unsolicited questions forwarded directly to me will
only be answered on a paid consulting basis." Does this mean when we reply
to the group don't include your name in the cc box??? Or just don't contact
me on topics not discussed in the newsgroups?
Kerri said:
Thank you Doug!
I will read up on that ariticle and give it a few tests!
Doug Robbins - Word MVP said:
Hi Kerri,
Record and Edit would not be of much use for something like this.
Some of what you will need is in the article "How to Find & ReplaceAll
on
a
Batch of Documents in the Same Folder" at:
http://www.mvps.org/word/FAQs/MacrosVBA/BatchFR.htm
but there will be a bit more coding required to be done. It is however
do-able.
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,
I have ~ 300 Word 2000 files that need to be setup as a mail merge
from
an
Access Query. I was hoping someone else has had the same issue. The
letters were once all WordPerfect mail merge files that have been
converted.
I tried the generic - record and edit - but I don't understand what causes
it to debug.
I would also like to be able to 'find' any fields like [42] and
replace
it
with the corresponding Access field name.
Thank you in advance for your suggestions.
Kerri