G
Greg Maxey
I type the word "One" in a document, select it and bookmark it as "BM"
I run this code:
Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("BM").Range
With oRng.Find
.Text = "One"
.Replacement.Text = "Two"
.Execute Replace:=wdReplaceOne
If .Found Then
oRng.Select
MsgBox "Item found"
End If
End With
End Sub
The oRng is selected, the message displays, but the replacement does
not occur.
If I add a space before or after the word "One" and include it in the
bookmarked range then the replacement does occur.
Can anyone explain why the replacement does not occur if the found text
includes the entire bookmarked range?
Thanks
I run this code:
Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("BM").Range
With oRng.Find
.Text = "One"
.Replacement.Text = "Two"
.Execute Replace:=wdReplaceOne
If .Found Then
oRng.Select
MsgBox "Item found"
End If
End With
End Sub
The oRng is selected, the message displays, but the replacement does
not occur.
If I add a space before or after the word "One" and include it in the
bookmarked range then the replacement does occur.
Can anyone explain why the replacement does not occur if the found text
includes the entire bookmarked range?
Thanks