How to remove blank paragraph

Hi,Everyone,

Who could tell me how to remove every blank paragraph in VB.net? please provide me a demo example.

Thanks!

Chen

Hi Chen,

Thanks for your inquiry. Following code example shows how to remove empty paragraphs from the document. Hope this helps you. Please let us know if you have any more queries.

Dim doc As New Document(MyDir + "in.docx")
For Each paragraph As Paragraph In doc.GetChildNodes(NodeType.Paragraph, True)
    If paragraph.ToString(SaveFormat.Text).Trim() = "" Then
        paragraph.Remove()
    End If
Next

A post was split to a new topic: Remove empty paragraphs in table’s cell