print the search results in Word

  • Follow


How do I print the search results from Word that includes the page number for 
each search result. Does anyone know a macro or does Microsoft Words have the 
option?
0
Reply Utf 2/7/2010 3:44:02 AM

The following macro will write the page number(s) of each occurrence of the 
searched text to a new document.

Dim oDoc, oNewdoc As Document
Dim sText, sPage As String
sText = InputBox("Enter text to find")
Set oDoc = ActiveDocument
Set oNewdoc = Documents.Add
oNewdoc.Range.Text = "'" & sText & "' found on page(s) "
oDoc.Activate
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
    Do While .Execute(findText:=sText) = True
        oNewdoc.Range.InsertAfter _
        Selection.Information(wdActiveEndPageNumber) & ", "
    Loop
End With
oNewdoc.Activate

http://www.gmayor.com/installing_macro.htm

-- 
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




"Willken" <Willken@discussions.microsoft.com> wrote in message 
news:53125B75-48D9-429D-8E7D-587F955158E7@microsoft.com...
> How do I print the search results from Word that includes the page number 
> for
> each search result. Does anyone know a macro or does Microsoft Words have 
> the
> option? 


0
Reply Graham 2/7/2010 7:38:18 AM

WHOOPEE! You are the best

0
Reply Utf 2/7/2010 3:45:01 PM

2 Replies
751 Views

(page loaded in 0.06 seconds)


Reply: