We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Deleting paragraph that contains specific text in word document

Thread ID:





130129 Apr 24,2017 09:59 AM UTC Apr 25,2017 10:25 AM UTC ASP.NET Web Forms 2
Tags: DocIO
Cubrilo Milos
Asked On April 24, 2017 09:59 AM UTC


I have a word template, with tables and fields set inside bookmarks.
There is an issue on some places when bookmarks are adjacent, line under line which creates an error on finding bookmarkEnd.
I managed to solve that by inserting paragraph of text in between.
Now I would like to remove all paragraphs in document, at the end before file is exported.
Paragraphs contain word "break" so I need to search and remove all those paragraphs.
Also it would be helpful to be able to remove(delete) previous and next empty paragraph if it is possible.

Cubrilo Milos
Replied On April 25, 2017 06:42 AM UTC

Solved with Syncfusion documentation -> File Formats -> DocIO -> Working with Word document

Only modification I had to make is instead of deleting it in an loop, to put paragraph indexes in a list and then after looping through the whole document reverse the list and delete all the indexes backwards, because in other case I would get index out of range exception.

Hope this helps someone.

Suganya Rathinam [Syncfusion]
Replied On April 25, 2017 10:25 AM UTC

Hi Cubrilo

Thank you contacting Syncfusion support.

We have prepared a sample to find the paragraph with specified text and remove that particular paragraph from the document using Find functionality of DocIO. Please find the sample from the following link and let us know if it helps.

Sample link

Things done in the sample:
1. Remove the paragraph with the specified text from the document.
2. Remove the empty paragraphs before and after the paragraph with the specified text from the document.

Please let us know if you need any further assistance.

Suganya R


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon