title: How can I add underlined words in a line of text in a word header object?
body: <p>I need to add underlined column headers to the header objects in a document. I am using C# and Microsoft.Office.Interop.Word</p>
  
  <p>The pertinent parts of the code look like this...</p>
  
  <pre><code>foreach (Word.HeaderFooter header in wordSection.Headers)
  {
      int[] fiscalYears = RetrieveFiscalYears(docProfile);
      string paddingFY = new String(' ', 8);
      Word.Paragraph colParagraph = wordRng.Paragraphs.Add();
  
      int year;
      for (int i = fiscalYears.Length - 1; i &gt;= 0; i--)
      {
          year = fiscalYears[i];
          colParagraph.Range.InsertAfter(MARKUP_WORD_TAB);
          //begin underline
          colParagraph.Range.InsertAfter(paddingFY + year.ToString() + paddingFY);
          //end underline
      }
      colParagraph.Range.InsertAfter(MARKUP_WORD_TAB);
      colParagraph = wordRng.Paragraphs.Add();
      colParagraph.set_Style(wordDoc.Styles["ColumnHeadings"]);
  }
  </code></pre>
  
  <p>Basically it needs to look similar to ...</p>
  
  <pre><code> Expended          Estimated          Budgeted
     2015               2016              2017
   ---------         ----------         --------
  </code></pre>
  
  <p>In the body of the document, my for loop looks like </p>
  
  <pre><code>foreach (int year in fiscalYears)
  {
      wordApp.Selection.TypeText(MARKUP_WORD_TAB);
      wordApp.Selection.Font.Underline = Word.WdUnderline.wdUnderlineSingle;
      wordApp.Selection.TypeText(paddingFY + year.ToString() + paddingFY);
      wordApp.Selection.Font.Underline = Word.WdUnderline.wdUnderlineNone;
  }
  </code></pre>
  
  <p>But the when I use the selection object, it writes to the body of the document, not to the header/footer objects. I might be able to get around this by using the SeekHeader and making it the focus, but that offers its own challenges...
  I've tried using the colParagraph.Range.Font.Underline object, but that underlines the entire line, not just the words that make up the column headings.
  I've tried using a find object, but the execute doesn't find the text for some reason.  </p>
  
  <p>Appreciate any guidance you can provide. </p>