Hi, I'm trying to look for s apecific word in a document in this case,
l.
And change all occurrences to
lecture.
However, if I use the macro below, it will change words like
roll. to rolLecture which is not what I want.
I only want to see words like
l.
and change them to Lecture.
Hope this makes sense. I have tried to sort this but to no avail. Thx in advance.
Sub ChangeWords_lat()
'
'
'
'
'WANT TO FIND WHOLE WORDS AND NOT PARTS OF WORDS AND REPLACE ONLY
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
MyString = "l.*"
StringLength = Len(MyString)
If StringLength = 2 Then
With Selection.Find
.Text = MyString
.Replacement.Text = "Lecture"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = True 'False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
' only works if alphabet letters are used
'- so command below can't be used on punctuation
' .MatchAllWordForms = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End If
End Sub