Delete Entire Line From Word Document

Is it possible to delete an entire line from a Word document (.docx) if a wildcard is found within that line? This is not always within a table, but rather within a paragraph.

Currently I am finding user-defined wildcards within a template Word doc, and replacing it with a user-entered value. But if the value is blank, I'd like to delete the line the wildcard was found in within the paragraph. If not possible, is it possible to perform this within a table?

Thank you.


3 Replies

MR Manikandan Ravichandran Syncfusion Team September 20, 2021 09:51 AM UTC

Hi DT,

Thank you for contacting Syncfusion support.

For your requirement of removing the particular line from the paragraph, we have prepared the sample and it can be download from the below link.
https://www.syncfusion.com/downloads/support/forum/168951/ze/F168951688753583

In this sample, we have included the logics for the followings.
1. Remove particular word in the Word document
2. Remove entire line in the Word document
3. Remove entire paragraph from the Word document.
4. Remove particular text in the table from the Word document.

Please refer the below link to know more about the find and replace functionality.
https://help.syncfusion.com/file-formats/docio/working-with-find-and-replace

Please let us know if you have any other queries.

Regards,
Manikandan Ravichandran 



DT Doug Thierjung September 20, 2021 05:01 PM UTC

Wow, thank you for the all the samples for this.

The method that I'm looking for in particular would be the delete line one. However in the sample, we know before-hand the entire line that we want to delete. My particular use-case is, if I have a wildcard within a line, how can I select the entire line it is located in, and then delete that.


As an example, this could be a paragraph that I am searching through:




If I wanted to find a wildcard in the above, say "290" and delete the entire line it is in (" Washington with 290 employees, several regional sales teams are located throughout "), is that possible to do currently? Or can I only programmatically find the entire paragraph?




MR Manikandan Ravichandran Syncfusion Team September 21, 2021 02:53 PM UTC

Hi DT,

Thank you for your update.

Yes, you can only delete the entire paragraph in which the given text is in or you can delete the given text alone using DocIO and you cannot delete the particular line based on the given single text If you want to remove entire line means, then you can find entire line from the paragraph instead of single text.

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran
 


Loader.
Up arrow icon