//// This code is part of Document Solutions for Word demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem;usingSystem.IO;usingGrapeCity.Documents.Word; namespaceDsWordWeb.Demos{// This sample shows how to replace all occurrences of a string // in a DOCX document (see JsFrameworkExcerpt) using the// RangeBase.Replace extension method provided by the// RangeBaseFindReplaceExtensions class.publicclassReplaceText {publicGcWordDocumentCreateDocx() {// The text to find:conststringtFind = "javascript";// The replacement:conststringtRepl = "ArabicaScroll"; // Load the original JsFrameworkExcerpt document:var doc = newGcWordDocument(); doc.Load(Path.Combine("Resources", "WordDocs", "JsFrameworkExcerpt.docx")); // Replace all occurrences of the search text in the document body// (note the option that we change from defaults):var nreplacements = doc.Body.Replace(tFind, tRepl, newFindReplaceOptions(doc) { IgnoreCase = true }); // Add a note at the end of the document: doc.Body.Sections.Last.GetRange().Paragraphs.Add($"DsWord replaced {nreplacements} occurrences of '{tFind}' with '{tRepl}' on {Util.TimeNow():R}."); // Done:return doc; } }}