title: C# Populate word template with OpenXml
body: <p>I would like to create a new Word document which is based on a template with content controls.</p>
  
  <p>I need to fill those contents controls (text).</p>
  
  <p>I only found how to generate a new Word document but not bases on a template.</p>
  
  <p>Do you have any link or tutorial ?</p>
  
  <p>Maybe am I wrong using OpenXml to fill a template ?</p>
  
  <pre><code>        // Create a Wordprocessing document. 
          using (WordprocessingDocument myDoc =
                 WordprocessingDocument.Create("d:/dev/test.docx",
                               WordprocessingDocumentType.Document))
          {
              // Add a new main document part. 
              MainDocumentPart mainPart = myDoc.AddMainDocumentPart();
              //Create Document tree for simple document. 
              mainPart.Document = new Document();
              //Create Body (this element contains
              //other elements that we want to include 
              Body body = new Body();
              //Create paragraph 
              Paragraph paragraph = new Paragraph();
              Run run_paragraph = new Run();
              // we want to put that text into the output document 
              Text text_paragraph = new Text("Hello World!");
              //Append elements appropriately. 
              run_paragraph.Append(text_paragraph);
              paragraph.Append(run_paragraph);
              body.Append(paragraph);
              mainPart.Document.Append(body);
              // Save changes to the main document part. 
              mainPart.Document.Save();
          } 
  </code></pre>