title: Is there a way to append the bookmark to a string in header using VBA for Word?
body: <p>I addressed all your comments and modified my code as per below:</p>
  <p>Sub HeaderFooterMacro()</p>
  <pre><code>'Delete the existing Header and Footer
  
  ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Delete
  ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Delete
  
  
  Dim headerRange As Range
  
  Set headerRange = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range
  With headerRange
          
      .ParagraphFormat.Alignment = wdAlignParagraphRight
      .Bookmarks.Add Range:=headerRange, Name:=&quot;DocID&quot;
      .Bookmarks.Add Range:=headerRange, Name:=&quot;UnderScore1&quot;
      .Bookmarks.Add Range:=headerRange, Name:=&quot;DocName&quot;
      .Bookmarks.Add Range:=headerRange, Name:=&quot;UnderScore2&quot;
      .Bookmarks.Add Range:=headerRange, Name:=&quot;DocVersion&quot;
      .InsertAfter Text:=vbTab &amp; vbTab &amp; &quot;Page &quot;
      .Collapse wdCollapseEnd
      .Fields.Add Range:=headerRange, Type:=wdFieldEmpty, Text:= _
        &quot;PAGE  \* Arabic &quot;
      .End = .Paragraphs(1).Range.End
      .Collapse wdCollapseEnd
      .InsertAfter Text:=&quot; of &quot;
      .Collapse wdCollapseEnd
      .Fields.Add Range:=headerRange, Type:=wdFieldEmpty, Text:= _
        &quot;NUMPAGES&quot;
        
  End With
  
                                                                     
  
  'Show the Form
  
  VersionForm.Show
  </code></pre>
  <hr />
  <p>Form:
  Private Sub OKBtn_Click()</p>
  <pre><code>Dim DocName, DocVersion, DocID, UnderScore1, UnderScore2 As Range
  
  Set DocID = ActiveDocument.Bookmarks(&quot;DocID&quot;).Range
  Set UnderScore1 = ActiveDocument.Bookmarks(&quot;UnderScore1&quot;).Range
  Set DocName = ActiveDocument.Bookmarks(&quot;DocName&quot;).Range
  Set UnderScore2 = ActiveDocument.Bookmarks(&quot;UnderScore2&quot;).Range
  Set DocVersion = ActiveDocument.Bookmarks(&quot;DocVersion&quot;).Range
      
  DocID.Text = Me.TextBox1.Value
  UnderScore1.Text = &quot;_&quot;
  DocName.Text = Me.TextBox2.Value
  UnderScore2.Text = &quot;_&quot;
  DocVersion.Text = Me.TextBox3.Value
  
  Me.Repaint
  VersionForm.Hide
  </code></pre>
  <p>End Sub</p>
  <p>Please find the screenshot below:</p>
  <p><a href="https://i.stack.imgur.com/AQnro.png" rel="nofollow noreferrer">Scrreenshot</a></p>
  <p>I am still getting &quot;DocVersion&quot; in the beginning. But, I need it in the format:
  &quot;DocID&quot;&quot;Underscore1&quot;DocName&quot;Underscore2&quot;DocVersion.
  Please help.</p>
  <p>And many thanks for your help :)</p>