Hi Team,
We have only kept the shape. how to delete the paragraph from the document. Please suggust.
Input: Input.docx (427.3 KB)
Excepted out: Excepted Out.docx (224.5 KB)
Regards,
Mahi
Hi Team,
We have only kept the shape. how to delete the paragraph from the document. Please suggust.
Input: Input.docx (427.3 KB)
Excepted out: Excepted Out.docx (224.5 KB)
Regards,
Mahi
@Mahi39 It looks like you mixed up the input and output documents. To remove all paragraphs except the one that contains the shape, you can use code like the following:
Document doc = new Document(@"C:\Temp\in.docx");
// Remove all runs from the paragraphs, which are immediate children of body.
foreach (Paragraph p in doc.FirstSection.Body.Paragraphs)
{
p.Runs.Clear();
// Remove paragraph if it becomes empty.
if (!p.HasChildNodes)
p.Remove();
}
doc.Save(@"C:\Temp\out.docx");