title: Replace Text in Word document using Open Xml
body: <p>I have created a docx file from a word template, now I am accessing the copied docx file and want to replace certain text with some other data.</p>
  <p>I am unable to get the hint as to how to access the text from the doument main part?</p>
  <p>Any help would be appreciable.</p>
  <p>Below is my code till now.</p>
  <pre><code>private void CreateSampleWordDocument()
      {
          string sourceFile = Path.Combine(&quot;D:\\GeneralWelcomeLetter.docx&quot;);
          string destinationFile = Path.Combine(&quot;D:\\New.docx&quot;);
          try
          {
              // Create a copy of the template file and open the copy
              File.Copy(sourceFile, destinationFile, true);
              using (WordprocessingDocument document = WordprocessingDocument.Open(destinationFile, true))
              {
                  // Change the document type to Document
                  document.ChangeDocumentType(DocumentFormat.OpenXml.WordprocessingDocumentType.Document);
                  //Get the Main Part of the document
                  MainDocumentPart mainPart = document.MainDocumentPart;
                  mainPart.Document.Save();
              }
          }
          catch
          {
          }
      }
  </code></pre>
  <p>Now how to find certain text and replace the same?
  I am unable to get via Link, so some code hint would be appreciable.</p>