View Single Post
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Proofreading macro

If you had the words to be replaced in column 1 of a table in a Word
document, starting in row 2 and the replacement words in column 2 of the
same table, and you save and close that document and open it when asked to
do so. The following macro run when the document in which you want the
replacements to be made is the active document should do what you want:

Dim i As Long
Dim rngFind As Range
Dim rngReplace As Range
Dim Source As Document
Dim Target As Document
Set Target = ActiveDocument
Target.TrackRevisions = True
With Dialogs(wdDialogFileOpen)
.Show
End With
Set Source = ActiveDocument
With Source.Tables(1)
For i = 2 To .Rows.Count
Set rngFind = .Cell(i, 1).Range
rngFind.End = rngFind.End - 1
Set rngReplace = .Cell(i, 2).Range
rngReplace.End = rngReplace.End - 1
With Target
.TrackRevisions = True
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=rngFind.Text, Forward:=True, _
MatchWildcards:=False, Replacewith:=rngReplace.Text, _
Wrap:=wdFindContinue, MatchCase:=False) = True
Loop
End With
End With
Next i
End With
Source.Close wdDoNotSaveChanges
Target.TrackRevisions = False




--
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, originally posted via msnews.microsoft.com

"Grey Old Man" wrote in message
...
I am looking for help to write a macro that will proofread a series of
large
documents for me.

A text file will be used for all suggested replacements. For example:

phone=telephone
fax=facsimile
&=and
24 x 7=24x7
7 x 24=24x7
mgmt=management

The macro will read the text file and find and replace as appropriate.
Track changes must be switched on at the start and switched off at the end
of the routine.

The reason for using a text file is for simplicity and easy maintenance
without knowledge of VBA code. Thanks in anticipation.