How do I set Word to Autocorrect when I copy/paste?

G

Guest

How do I set up a function in Word to automaticly replace certain words
without having to input an entire list for each document. I copy/paste a
document into Word from another program and then have to use the "replace"
feature dozens of times. Is there anyway to save these replacements and have
Word perform them automaticly? Or else run the list for me when I manually
execute the autocorrect?
I am using Word 93.
 
G

Graham Mayor

Create your common list of replacements in a two column table - first column
the words you are looking for, the second with their replacements. Save the
document then run the following macro having changed the filename and path
of the table document in the line:
Set ChangeDoc = Documents.Open("D:\My Documents\Test\changes.doc")

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.doc")
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

See http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top