I wrote a simple macro to create a "text like" representation of a Write
document containing a header and/or footer with the current page number.
The view cursor traverses the pages, extracting header, text, and footer.
The interesting thing for me was that the header/footer content is
static and does not update based on the location of the view cursor
(footer contained the page number). In retrospect, I can understand why
this is so, but I was also a bit surprised.
Any comments on this behavior?
Sub ExportText()
Dim oDoc
Dim oCurs
Dim oVC
Dim oStyles
Dim oStyle
Dim s$
oDoc = ThisComponent
oStyles = oDoc.StyleFamilies.getByName("PageStyles")
oVC = oDoc.currentController.getViewCursor()
oVC.gotoStart(False)
oCurs = oVC.getText().createTextCursorByRange(oVC)
REM Assume at the top of the loop that at the start of a new page
Do
oStyle = oStyles.getByName(oVC.PageStyleName)
oCurs.gotoRange(oVC, False)
oVC.jumpToEndOfPage()
oCurs.gotoRange(oVC, True)
If oStyle.HeaderIsOn Then
s = s & oStyle.HeaderText.getString() & CHR$(13) & CHR$(10)
End If
s = s & oCurs.getString() & CHR$(13) & CHR$(10)
If oStyle.FooterIsOn Then
s = s & oStyle.FooterText.getString() & CHR$(13) & CHR$(10)
End If
If NOT oVC.jumpToNextPage() Then Exit Do
Loop
MsgBox s
End Sub
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]