What do you want to do with the words when found?
The following macro will read the words in the first column of a spreadsheet
and replace them with the second. It was originally written (it looks like
fellow MVP Doug Robbins' code) to work with a Word table document
(changes.doc) but if you have the old Excel converter which you can download
from my web site and which will allow the sheet to be opened in Word, it
will work with an Excel XLS sheet called here "D:\My
Documents\Test\changes.xls"
Sub ReplaceFromTableList()
Dim ChangeDoc As Document, RefDoc As Document
Dim ctable As Table
Dim oldpart As Range, newpart As Range
Dim i As Long
Set RefDoc = ActiveDocument
Set ChangeDoc = Documents.Open("D:\My Documents\Test\changes.xls")
Set ctable = ChangeDoc.Tables(1)
RefDoc.Activate
For i = 1 To ctable.Rows.Count
Set oldpart = ctable.Cell(i, 1).Range
oldpart.End = oldpart.End - 1
Set newpart = ctable.Cell(i, 2).Range
newpart.End = newpart.End - 1
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Execute findText:=oldpart, _
ReplaceWith:=newpart, _
replace:=wdReplaceAll, _
MatchWildcards:=False, _
Forward:=True, _
Wrap:=wdFindContinue
End With
Next i
ChangeDoc.Close wdDoNotSaveChanges
End Sub
You should be able to modify the code to do whatever you want with the found
words.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>