Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Word .NET
>
Tutorial
> Replace text
The example shows you how to open a document and replace text.
C# example
using System; using Independentsoft.Office; using Independentsoft.Office.Word; namespace Sample { class Program { static void Main(string[] args) { WordDocument doc = new WordDocument("c:\\test\\input.docx"); doc.Replace("[CustomerID]", "12345"); doc.Replace("[CustomerName]","John Smith"); doc.Save("c:\\test\\output.docx", true); } } }
VB example
Imports System Imports Independentsoft.Office Imports Independentsoft.Office.Word Module Module1 Sub Main(ByVal args As String()) Dim doc As WordDocument = New WordDocument("c:\test\input.docx") doc.Replace("[CustomerID]", "12345") doc.Replace("[CustomerName]", "John Smith") doc.Save("c:\test\output.docx", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*