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.

How to retrieve the content of a page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Inbar - 09 Nov 2004 23:28 GMT
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?
 
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.