I am looking for a way to retrieve the text content of a page. I didn't seem
to find an easy way to do this in vba. Any ideas?
Helmut Weber - 10 Nov 2004 00:39 GMT
Hi,
are you lookong for:
Selection.Bookmarks("\page").Range.Select,
which selects the page the beginning of the selection is on.
But you may have to switch just once to printview beforehand.
And I can't think of a way to get the content of a specific page
without moving the selection to that page. Once it is there,
the following would be an alternative.
dim s as string
s = Selection.Bookmarks("\page").Range.text
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Chuck - 10 Nov 2004 16:48 GMT
In addition to Helmut's suggestion, you can also use a range to navigate to a
specific page, then use the "\page" bookmark to select the content of that
page:
Sub GetPageContents()
Dim rngRange As Range
Dim lngPageNum As Long
lngPageNum = InputBox("What page?")
'you can determine the page number you want in code
'or through a user interaction such as InputBox etc
Set rngRange = ActiveDocument.GoTo _
(What:=wdGoToPage, _
Which:=wdGoToAbsolute, _
Count:=lngPageNum)
'you can set the GoTo params as you like
rngRange.Select
Set rngRange = ActiveDocument.Bookmarks("\Page").Range
'Now you have the contents of the page as a range object,
'you can do what you need to do with the range object
End Sub
Hope this helps...
> I am looking for a way to retrieve the text content of a page. I didn't seem
> to find an easy way to do this in vba. Any ideas?