title: Inserting text and fields in Word 2010 header without using .Select
body: <p>I am trying to fix up a Word 2010 page header containing fields for filename, save date and page number as well as some text between each, like so: filename+" "+save date+tab+page number. However, I can't seem to get the strings in their right places. What I have so far is this:</p>
  
  <pre><code>Sub CreateHeader()
      Dim myRange As Range
      With ActiveDocument
          Set myRange = .Sections(1).Headers(wdHeaderFooterPrimary).Range
          .Fields.Add Range:=myRange, Type:=wdFieldFileName, PreserveFormatting:=True
          myRange.Collapse wdCollapseEnd
          myRange.InsertAfter (" ")
          myRange.Collapse wdCollapseEnd
          .Fields.Add Range:=myRange, Type:=wdFieldSaveDate, Text:="\@ YYYY-MM-DD", PreserveFormatting:=True
          myRange.InsertAfter (Chr(9))
          myRange.Collapse wdCollapseEnd
          .Fields.Add Range:=myRange, Type:=wdFieldPage, PreserveFormatting:=True
      End With
  End Sub
  </code></pre>
  
  <p>However, after executing the sub, the different parts are not were I intend. Instead, they show up as filename+" "+tab+page number+save date. What am I doing wrong here? If it is at all possible, I would prefer not resorting to <code>.Select</code>.</p>
  
  <p>(Please note that I recently asked <a href="https://stackoverflow.com/questions/14710750/insert-two-fields-in-word-2010-page-header-using-vba">a similar question</a>.)</p>