title: Merge cells of tables in the header in Word VBA
body: <p>I would like to merge two cells of the second table in the header of my Word document. I created the script below but it has a run-time error: '5491'.The requested member of the collection does not exist.</p>
  <p>The error occured on this line&quot; With xTable(2)&quot;</p>
  <pre><code>Sub mergercells()
      
      Set xTable = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables
  
   With xTable(2)
   .Cell(Row:=3, Column:=2).Merge _
   MergeTo:=.Cell(Row:=3, Column:=1)
   .Borders.Enable = False
   End With
  
  End Sub
  </code></pre>
  <p>Thanks,</p>