title: OpenXml Edit text in the header of a word file
body: <p>I'm using Open XML and I should change the text in the header of a word file. To change a specific paragraph in the document I have used the following code:</p>
  
  <pre><code>Dim body = wdDoc.MainDocumentPart.Document.Body
              Dim paras = body.Elements(Of DocumentFormat.OpenXml.Wordprocessing.Paragraph)()
              Dim header = body.Elements(Of DocumentFormat.OpenXml.Wordprocessing.Header)()
  
  
              For Each para In paras
                  For Each run In para.Elements(Of DocumentFormat.OpenXml.Wordprocessing.Run)()
                      For Each testo In run.Elements(Of DocumentFormat.OpenXml.Wordprocessing.Text)()
                          If (testo.Text.Contains("&lt;$doc_description$&gt;")) Then
                              testo.Text = testo.Text.Replace("&lt;$doc_description$&gt;", "replaced-text")
                          End If
                      Next
                  Next
              Next
  </code></pre>
  
  <p>thanks in advance!</p>