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 / January 2006

Tip: Looking for answers? Try searching our database.

finding automatic page breaks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy Fish - 27 Jan 2006 09:34 GMT
Nice easy question for you Word programming experts :)

How can I detect where the automatic page breaks have been put in a
document?

TIA
Andy
Helmut Weber - 27 Jan 2006 11:49 GMT
Hi Andy,

>How can I detect where the automatic page breaks have been put in a
>document?

hmm...

at the start of pages, or to be more precise,
a pagebreak is there, where Word depending on paper
and printer etc. thinks, a new page has to start.

In fact, the automatic pagebreaks, IMHO,
aren't in the document at all, but calculated
at runtime.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Andy Fish - 27 Jan 2006 13:02 GMT
> Hi Andy,
>
[quoted text clipped - 10 lines]
> aren't in the document at all, but calculated
> at runtime.

well, I can see the pages in the object model  - something like

   ActiveDocument.ActiveWindow.Panes(1).Pages

so I know that it does expose some information about the pages. However,
this doesn't allow me to idenfify which text is on which page.
Helmut Weber - 27 Jan 2006 13:32 GMT
Hi Andy,

maybe something rather simple:

Sub MacroX()
' text on page 2
Selection.GoTo what:=wdGoToPage, _
which:=wdGoToAbsolute, _
Count:=2
Selection.Bookmarks("\page").Select
End Sub

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Helmut Weber - 27 Jan 2006 22:27 GMT
Hi Andy,

which text on which page?

That's another question.

Like this, which returns the page number,
on which the start of the first occurence
of a string is to be found.
Zero if not found.

Public Function OnWhichPage(sTmp As String) As Long
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
  .Text = sTmp
  If .Execute Then
     rDcm.Collapse
     OnWhichPage = rDcm.Information(wdActiveEndPageNumber)
  Else
     OnWhichPage = 0
  End If
End With
End Function

Sub test09876()
MsgBox OnWhichPage("Meier")
End Sub

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Andy Fish - 30 Jan 2006 10:09 GMT
Thanks for your help Helmut.

To be honest I'm not sure precisely what I am asking for yet :)

my aim is to put some kind of markers in the document so that when I save it
as XML (WordProcessingML) I can see where the page breaks are when looking
in the XML document. I don't really know how to approach this yet, so I was
just fishing for general information about associating page numbers with
paragraphs.

It seems like Range.Information(wdActiveEndPageNumber) is the most likely
candidate - though it's still not ideal

Andy

> Hi Andy,
>
[quoted text clipped - 24 lines]
> MsgBox OnWhichPage("Meier")
> End Sub
Tony Jollans - 27 Jan 2006 14:02 GMT
Helmut is, of course, correct. Automatic page breaks do not exist anywhere
in the document, only, if at all, in Word's short-term memory.

You can go to the start of a page like this ..

       Selection.GoTo wdGoToPage, 17

.. and Selection.Start will tell you where the page break between pages 16
and 17 is, for example.

--
Enjoy,
Tony

> Hi Andy,
>
[quoted text clipped - 18 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"

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.