title: DocX - Insert Table at Specified Index
body: <p>I have developed a WinForms application which utilises the DocX Library for editing .docx files in memory.</p>
  
  <p>I have one issue which i have searched Google vigorously, this is I would like to add a Table to my document using a specific index.</p>
  
  <p>I do this by already having a blank table in the document and then finding the index and replacing the table with my table from my app using the index from the pre-existing table. I end up with this error:</p>
  
  <p><strong>Location: Part: /word/document.xml, Line: 22, Column: 0</strong></p>
  
  <p>I do not know if this is a DocX glitch or that I have approached this wrong.</p>
  
  <p>The code below is not my app but some basic code which my app utilises.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using Novacode;
  
  namespace DocXTesting
  {
  class Program
  {
      static void Main(string[] args)
      {
  
          using (DocX document = DocX.Load(@"Test.docx"))
          {
              Table t = document.Tables[0];
              int tIndex = t.Index;
  
              try
              {
                  t.Remove();
  
                  Table newTable = document.InsertTable(tIndex, 4, 4);
                  document.Save();
  
              }
              catch (Exception x)
              {
                  Console.WriteLine(x.Message);
              }
  
          }
          Console.ReadKey();
  
      }
  }
  </code></pre>
  
  <p>}</p>