J
junya55
Hi.
Please tell me how to get non-overlapped page numbers indicating
the pages, in wihch the found text exists in a document.
For example, when "steel" is shown twice in page 3 and three times in
page 5,
the following code returns the page numbers like, "page: 3, 3, 5, 5,
5, ".
Could you give me any advice to remove the overlapped page numbers
such
that the following code returns "page: 3, 5, " instead?
The code is shown below.
thanks in advance.
junya
.................................................................................
Sub page_search()
Dim myRange As Range
Dim pageNum As String
Set myRange = Selection.Range
Selection.HomeKey Unit:=wdStory
With myRange.Find
.Wrap = wdFindStop
.MatchWholeWord = True
.Execute FindText:="steel", Forward:=True
End With
Do While myRange.Find.Found = True
pageNum = pageNum & _
myRange.Information(wdActiveEndPageNumber) _
& ", "
myRange.Find.Execute
Loop
MSGBOX "page: " & pageNum
End Sub
Please tell me how to get non-overlapped page numbers indicating
the pages, in wihch the found text exists in a document.
For example, when "steel" is shown twice in page 3 and three times in
page 5,
the following code returns the page numbers like, "page: 3, 3, 5, 5,
5, ".
Could you give me any advice to remove the overlapped page numbers
such
that the following code returns "page: 3, 5, " instead?
The code is shown below.
thanks in advance.
junya
.................................................................................
Sub page_search()
Dim myRange As Range
Dim pageNum As String
Set myRange = Selection.Range
Selection.HomeKey Unit:=wdStory
With myRange.Find
.Wrap = wdFindStop
.MatchWholeWord = True
.Execute FindText:="steel", Forward:=True
End With
Do While myRange.Find.Found = True
pageNum = pageNum & _
myRange.Information(wdActiveEndPageNumber) _
& ", "
myRange.Find.Execute
Loop
MSGBOX "page: " & pageNum
End Sub