Remove section with script

Anybody have idea how to remove section itself, not text in it, with script? notesRichTextSection.Remove removes section and text in it.

I mean kind of remove like when document is in edit mode and you select section and from section menu select remove. Section is removed, but text inside section remains.

Subject: Remove section with script

I don’t think the native classes have any way to do it, except perhaps by dumping to DXL and modifying the DXL and re-importing. Our Midas Rich Text LSX has a method called RemoveSection, for what it is worth, but unless you want Midas for other rich text manipulation, you might want another approach.

Subject: RE: Remove section with script

Can you remove all sections from selected documents with Midas?

Subject: RE: Remove section with script

Sure. The code to remove all sections from all documents in a collection would be:

Dim rtitem As New GeniiRTItem

… other code …

Set doc = collection.GetFirstDocument

While Not (doc Is Nothing)

Call rtitem.ConnectBackend(doc.Handle, “Body”, True)

If rtitem.Everything.GetCount(“Section”) > 0 Then

 Call rtitem.Everything.RemoveSections()

 Call rtitem.Save()

End If

Set doc = collection.GetNextDocument(doc)

Wend

Note that this would not modify any document without sections, and also note that the rtitem.Save is sufficient, and you shouldn’t do a doc.Save as well. Hope that helps.

Subject: Remove section with script

Kake:

Try this:

  1. RTNav set to NotesRichTextNavigator

  2. Find the Section (RTELEM_TYPE_SECTION)

  3. Navigate to the next element (should be your text)

  4. Create a NotesRichTextRange

  5. Set the beginning of the range to this element (SetBegin)

  6. Navigate (GetNextElement) until the type is no long RTELEM_TYPE_TEXTPARAGRAPH

  7. Set the end of the Range (SetEnd)

  8. Copy the text to an in memory variable

  9. Navigate back to beginning of document

  10. Find the section

  11. Remove the section

  12. Insert the text saved in the in memory variable

Should work

HTH

Don

Subject: RE: Remove section with script

1&2 no problems. 3. Navigate to next what element? RTELEM_TYPE_TEXTPARAGRAPH (4) or

RTELEM_TYPE_TEXTRUN (3) or what?

  1. How I copy text from textrange to variable?

Subject: RE: Remove section with script

TextParagraph property Read-only. The text in the range starting at the beginning and ending with a new paragraph.

Call rtrange.SetBegin(rtnav)

localVariable = rtrange.TextParagraph

Don

Subject: RE: Remove section with script

Basicly I know how to deal with texts. But…Section can contain tables and text etc. How can I copy all elements from inside of the section to its outside?

Subject: Remove section with script

  • Sounds like you mean “collapse” the section, as opposed to “remove”. Is this the case?

Subject: RE: Remove section with script

No. I want to take out text from the section. I think @Command( [SectionRemoveHeader] ) is how it’s done with formula.