DocBuilder

I am using a word document as a template and using Document Builder to create the document.

I have a section in the word document that I need deleted under certain conditions.

How do I specify to delete the section from the doc?

I thought this would do it:

Console.WriteLine(oDoc.GetText())
oDoc.Sections(3).Range.Delete()
Console.WriteLine(oDoc.GetText())

Maybe not specifying the document correctly in code?

Dim oDoc As Document

Hi Jerry,

Thanks for your inquiry. Please use the Section.Remove method to remove the section node.

Moreover, DocumentBuilder.CurrentNode property gets the node that is currently selected in this DocumentBuilder. You may move to the cursor to specified position in the document using DocumentBuilder.MoveTo method and get the current Section node. After getting the section node, please use Section.Remove method to remove the section.

Please let us know if you have any more queries.

DocumentBuilder.CurrentNode.GetAncestor(NodeType.Section).Remove()