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.
Unfortunately, activation email could not send to your email. Please try again.

Deleting paragraph that contains specific text in word document

Thread ID:

Created:

Updated:

Platform:

Replies:

130129 Apr 24,2017 05:59 AM Apr 25,2017 06:25 AM ASP.NET Web Forms 2
loading
Tags: DocIO
Cubrilo Milos
Asked On April 24, 2017 05:59 AM

Hello,

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 02:42 AM

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 06:25 AM

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.

Regards,
Suganya R


CONFIRMATION

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.

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.

;