Page number

B

Bill Taylor

I need to find text in a large document and then find it's location (page #
?). I am automating this from Access and I want to store the location (page
numbers) in a table to use later to go to that page. How should I go about
this? Help.......
 
P

Perry

Here's one example

Dim wdApp As New Word.Application
Dim doc As Word.Document
Dim r As Word.Range

Set doc = wdApp.Documents.Open("c:\temp\MySearchDoc.doc")
Set r = doc.Content

With r.Find
.ClearFormatting
.Text = "My_Search_String"
.Execute
End With

'retrieve pagenumber using information property of a range
'Note: first instance of searchstring
MsgBox r.Information(wdActiveEndPageNumber)

doc.Close 0
wdApp.Quit: Set wdApp = Nothing

Krgrds,
Perry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top