This is my first VBA attempt in Word. I want to Find multiple word matches and Replace All of them with the string I specify, preferably from an outside document. I have 1000 different words I want to replace with their 1000 different translations in a 200 page document. Now I'm stuck, because I can't get this function to work on my Word 2010 text. Is this code correct and how can I implement it?
Function R(StrFind As String, StrReplace As String)
Application.ScreenUpdating = False
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = StrFind
.Replacement.Text = StrReplace
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
MsgBox R("q", "a")
MsgBox R("w", "a")
MsgBox R("e", "a")
MsgBox R("r", "a")
MsgBox R("t", "a")
MsgBox R("y", "a")
ActiveDocument.UndoClear
Application.ScreenUpdating = True
End Function