Mark Walker wrote:
Hi
I have a writer document that contains a section called "security".
The section is at the top of the first page & is hidden.
The section contains the text "Main password list".
Via a macro how can I extract the text from within this section.
Regards
MARK
I added a section to my free macro document just for you.
Text sections
A TextSection is a range of complete paragraphs contained a text object.
The content may be the content of a link into another document, a link
from the same document, or the result of a DDE operation. TextSection
instances can be linked from, and to, other texts. The contents of a
text section are enumerated along with regular text and can be traversed
with a text cursor. The text is traversed even if it is marked as not
visible, which you can check with the oSection.IsVisible property.
Listing 7.57: Display the text in the first text section
REM Author: Andrew Pitonyak
Sub GetTextFromTextSection
Dim oSection
Dim oCurs
If ThisComponent.getTextSections().getCount() = 0 Then
Print "There are no text sections"
Exit Sub
End If
REM You can get a text section by name or index.
'oSection = ThisComponent.getTextSections().getByName("Special")
oSection = ThisComponent.getTextSections().getByIndex(0)
REM Create a cursor and move the cursor to the text section.
oCurs = ThisComponent.getText().createTextCursor()
oCurs.gotoRange(oSection.getAnchor(), False)
REM In this example, I assume that there is text after
REM the text section. If there is not, then this is
REM an infinite loop. You had better verify that
REM gotoNextParagraph does not return False.
Do While NOT IsEmpty(oCurs.TextSection)
oCurs.gotoNextParagraph(False)
Loop
oCurs.gotoPreviousParagraph(False)
oCurs.gotoRange(oSection.getAnchor(), True)
MsgBox oCurs.getString()
End Sub
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw
My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm
Free Info: http://www.pitonyak.org/oo.php
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]