J
JenFruels
Hi,
Does anybody know how to search for a certain word in a specific
selection/highlighted text/paragraph of a document only? I have tried
recording a macro but I was not able to get what I want. The following code
will highlight the paragraph/portion where the enclosing bookmark is located.
In that highlighted/selected area, the macro will search for the word
"hello". I only want the macro to find those which are only within the
selection. I know this is possible when using the Search & Replace Dialog box
but I can't make it run on macro. Below is my sample code.I can't figure out
what's missing. I am using Word 2003. Thanks.
Sub LinkTest()
Dim a As String
Selection.GoTo What:=wdGoToBookmark, Name:="tmp"
With Selection.Find
.text = "hello"
End With
Do
a = Selection.Find.Execute
If a = True Then
MsgBox (Selection.text)
End If
Loop While a = True
End Sub
Does anybody know how to search for a certain word in a specific
selection/highlighted text/paragraph of a document only? I have tried
recording a macro but I was not able to get what I want. The following code
will highlight the paragraph/portion where the enclosing bookmark is located.
In that highlighted/selected area, the macro will search for the word
"hello". I only want the macro to find those which are only within the
selection. I know this is possible when using the Search & Replace Dialog box
but I can't make it run on macro. Below is my sample code.I can't figure out
what's missing. I am using Word 2003. Thanks.
Sub LinkTest()
Dim a As String
Selection.GoTo What:=wdGoToBookmark, Name:="tmp"
With Selection.Find
.text = "hello"
End With
Do
a = Selection.Find.Execute
If a = True Then
MsgBox (Selection.text)
End If
Loop While a = True
End Sub