.NET Word Library - Find and Replace in Word Documents using C#
- Effortlessly find and replace text in Word documents with C#.
- Advanced options: Replace text with document elements or content from another document.
- Find document elements like images, charts, and fields based on element properties.
Try C# Word Examples in Playground app.
FREE TRIALNo credit card required.
Explore ExamplesNo credit card required.
Trusted by the worldโs leading companies
.NET word library find and replace
Overview
Streamline your Word document editing with the Syncfusion .NET Word Library. By using C#, you can find and replace text with dynamic elements, including images, hyperlinks, paragraphs, tables, or even an entire document. This functionality operates without Microsoft Word or interop dependencies. Refine your searches by using options for case-sensitivity and whole-word matches.
Find and replace in Word document using C#
This example code shows how to find and replace text in a Word document using the Syncfusion .NET Word Library with just a few lines of C# code.
Key features of the Find functionality
Find text
Find text in a Word document based on a specific pattern using a regular expression (regex) or a normal string. You can search the entire document or within a specific paragraph.
Casing and whole words
Refine the find operation by matching the casing or whole word for precise results.
Find first
Find only the first occurrence of a piece of text in a Word document.
Find all
Find all the occurrences of a text length in all parts of a Word document, including the body, header, footer, shapes, comments, footnotes, and endnotes.
Find next
Find the next occurrence of a specified text in a Word document.
Find multiline text
Find the first or next occurrence of a text that extends across several paragraphs.
Features of the Replace functionality
Replace text
Perform a find and replace operation for the text in a Word document and track the total number of replacements made. You can find a static text or specific pattern using a regular expression (regex).
Replace first
Replace only the first occurrence of the specified text in a Word document.
Replace with document
Replace the searched text with document elements such as paragraphs, tables, and content controls while maintaining the source formatting.
Replace with document elements
Replace the searched text with document elements such as paragraphs, tables, and content controls while maintaining the source formatting.
Replace with selection
Find and retrieve text with formatting (bold, highlight) for replacement in occurrences of other placeholders in a Word document, maintaining that formatting.
Replace multiline text
Replace all text occurrences spanning multiple paragraphs with the replacement text or document elements.
Features of Find elements
Find the element by properties
Locate the first Word document element that matches a specified property or a collection of properties. For example, find a picture by its alternative text or a chart by its title and type.
Find all elements by properties
Find all elements that match a specified property or a collection of properties. For example, find all fields of a specific type or all content controls with a specific title and tag.
Explore find and replace references
Check our blog and knowledge base articles to improve your efficiency with find and replace functionalities in Word documents.
๐ Explore 7 Useful Ways to Find and Replace Text in Word Documents
Blog
Explore 7 Useful Ways to Find and Replace Text in Word Documents Using C#
๐ Find and replace text with a hyperlink in Word documents using C#
Knowledge base
How to find and replace text with a hyperlink in Word documents using C#
๐ Find and replace text with a chart in a Word document
Knowledge base
How to find and replace text with a chart in a Word document
๐ Find and replace text with a Table of Contents (TOC) in a Word document
Knowledge base
How to find and replace text with a Table of Contents (TOC) in a Word document
๐ Replace text in a Word document with HTML using C#
Knowledge base
How to replace text in a Word document with HTML using C#
๐ Find and replace text inside a table in a Word document
Knowledge base
How to find and replace text inside a table in a Word document
Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.
Frequently Asked Questions
Does the .NET Word Library support searching for text based on case sensitivity or whole word matching criteria?
Yes, you can customize the find functionality in the .NET Word library to search the text based on criteria such as case sensitivity and whole-word matching.
Does this .NET Word library offer options for formatting the found text occurrences like highlighting and more?
Yes. Besides finding and highlighting, you can format the found text with options such as bold, underline, font size, and more.
Is finding document elements like images, charts, tables, and more similar to finding text?
Yes, like finding text in a Word document, the .NET Word Library offers options to find Word document elements based on their properties.
Can I replace text with other elements like images, hyperlinks, or tables?
Yes, you can replace text with Word document elements such as images, hyperlinks, tables, and more.
Can I find and replace text in a specific paragraph alone?
Yes, using the .NET Word Library, you can find and replace text in a specific paragraph.
How can I integrate find and replace functionalities into my application?
You can access it through the Syncfusion.DocIO.Net.Core NuGet package. The documentation provides detailed code samples, facilitating seamless integration.
Our Customers Love Us
Here are some of their experiences.
See Real Success Stories
Developers around the world trust Syncfusionโs Essential Studio to simplify complex projects and speed up delivery. With a vast library of UI controls, powerful SDKs, and reliable support, Essential Studio helps teams build enterprise-ready applications with confidence.
Read Our Customer StoriesIndustry
Software development
75% Cost reduction
50% Faster development
โIf somebody is looking for a great tool to work with? Yes. I would definitely recommend Syncfusion for anyone who is trying to develop something meaningful.โ
- Somnath Maji (Founder of Igniatek Consultancy)
Read StoryIndustry
Utilities (oil and gas)
Advanced, flexible features
Empowered users through robust and versatile functionality.
โSyncfusionโs tools have taken care of many things so I can focus on developing the application, instead of developing tools for the application.โ
- James Athyal (Software developer, McDaniel & Associates Consultants Ltd)
Read StoryIndustry
Software and technology
Efficient file management
Streamlined workflows with document libraries without building them from scratch.
โWe really love when the magic happens.โ
- Irvin Dominin (BUILDER WEB Development Manager at Sistemi)
Read StoryIndustry
Software and technology
โWe are Syncfusion fans because of the way Syncfusion treats the support.โ
- Dr. Howard Rybko (CEO of Synchrony Digital)
Read StoryIndustry
IT services and IT consulting
Improved performance
Large datasets handled with easy customization and quick debugging.
Highly customizable
Plug-and-play controls with quick template integration.
โI will surely recommend Syncfusion to others as a third-party control because I think itโs very easily customizable.โ
- Jayesh (Technical Team Lead, Capita)
Read StoryIndustry
Professional services
โWe definitely wanted Syncfusion to help us with our document processing functionality, and we were happy with and satisfied with Syncfusion.โ
- Arvind Naik (Engineering Lead, Vialto Partners)
Read StoryRated by users across the globe
Want to create, View, and edit Word documents in C# or VB.NET?
No credit card required.
Awards
Greatnessโitโs one thing to say you have it, but it means more when others recognize it. Syncfusionยฎ is proud to hold the following industry awards.
