Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Page Number

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ulf Nilsson - 29 Nov 2004 10:11 GMT
Hi,
If I search a document and a word is found on page 3, how
can I return the page number to the code? I have only
found how to return the page number the cursor is located
on, but not where the word is found.

/ Ulf
Helmut Weber - 29 Nov 2004 10:33 GMT
Hi Ulf,
like this:

Sub Test007
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
ActiveDocument.ComputeStatistics (wdStatisticPages)
ResetSearch
With rDcm.Find
  .Text = "comx"
  If .Execute Then
     MsgBox rDcm.Information(wdActiveEndPageNumber)
     ' found on page ....
  End If
End With
end sub

Public Sub ResetSearch()
With Selection.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = ""
  .Replacement.Text = ""
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .Execute
End With
End Sub

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Ulf Nilsson - 29 Nov 2004 11:53 GMT
Thanks Helmut!

/ Ulf
>-----Original Message-----
>Hi Ulf,
[quoted text clipped - 38 lines]
>
>.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.