VBA : Insert multiple table in documnet
<p>I have a little problem with VBA for Microsoft Word. I want to add multiple table in a document file. The first one work ok. When i try to add the second it says that the tabel with index 2 doesn't exit.
Could you give me some help?
Thanks</p>

<p>Here is my code :</p>

<pre><code>Dim oDoc As Document
Dim oRng As Range


Set oDoc = ActiveDocument
Set oRng = oDoc.Range(0, 0)




'Tabel 1
oDoc.Tables.Add Range:=oRng, NumRows:=3, NumColumns:=2


oDoc.Tables.Item(1).Range.AutoFormat
oDoc.Tables.Item(1).Borders.OutsideLineStyle = wdLineStyleSingle
oDoc.Tables.Item(1).Borders.InsideLineStyle = wdLineStyleSingle
oDoc.Tables.Item(1).Range.Paragraphs.SpaceBefore = 12
oDoc.Tables.Item(1).Range.Paragraphs.SpaceAfter = 0
oDoc.Tables.Item(1).Range.Paragraphs.Alignment = wdAlignParagraphLeft
oDoc.Tables.Item(1).Range.Font.Size = 11
oDoc.Tables.Item(1).Range.Font.Name = "Arial"
oDoc.Tables.Item(1).AutoFitBehavior (wdAutoFitContent)
oDoc.Tables.Item(1).Rows.Alignment = wdAlignRowCenter
oDoc.Tables.Item(1).Cell(1, 1).Range.Text = "Code"
oDoc.Tables.Item(1).Cell(2, 1).Range.Text = "Issue"
oDoc.Tables.Item(1).Cell(3, 1).Range.Text = "Date"
oDoc.Tables.Item(1).Cell(1, 2).Range.Text = "GEURIW-PM1-TN-02"
oDoc.Tables.Item(1).Cell(2, 2).Range.Text = "0.1"
oDoc.Tables.Item(1).Cell(3, 2).Range.Text = "20/12/2015"
oDoc.Paragraphs.Add

Set aRange = ActiveDocument.Paragraphs(1).Range
oDoc.Tables.Add Range:=Range(0.1, 0.1), NumRows:=1, NumColumns:=1
oDoc.Tables.Item(2).Borders.OutsideLineStyle = wdLineStyleSingle
oDoc.Tables.Item(2).Cell(1, 1).Range.InsertBefore "GNSS ENVIRONMENT AND USER    REQUIREMENTS CHARACTERISATION ON THE DANUBE RIVER"
oDoc.Tables.Item(2).Cell(1, 1).Range.Bold = True
oDoc.Tables.Item(2).Cell(1, 1).Range.Font.Size = 18
oDoc.Tables.Item(2).Cell(1, 1).Range.Font.Name = "Trebuchet MS"
oDoc.Tables.Item(2).Cell(1, 1).Range.Paragraphs(1).Format.Alignment = wdAlignParagraphCenter
oDoc.Tables.Item(2).Cell(1, 1).Range.Paragraphs(1).SpaceBefore = 10
oDoc.Tables.Item(2).Cell(1, 1).Range.InsertAfter vbCrLf + "GEURIW"
oDoc.Tables.Item(2).Cell(1, 1).Range.Paragraphs(2).Format.Alignment = wdAlignParagraphCenter
oDoc.Tables.Item(2).Cell(1, 1).Range.Paragraphs(2).Range.Font.Size = 26
oDoc.Tables.Item(2).Cell(1, 1).Range.Paragraphs(2).SpaceBefore = 10
oDoc.Tables.Item(2).Cell(1, 1).Range.InsertAfter vbCrLf + "DATA PROCESSING METHODOLOGY"
oDoc.Tables.Item(2).Cell(1, 1).Range.Paragraphs(3).Format.Alignment = wdAlignParagraphCenter
oDoc.Tables.Item(2).Cell(1, 1).Range.Paragraphs(3).Range.Font.Size = 18
oDoc.Tables.Item(2).Cell(1, 1).Range.Paragraphs(3).SpaceBefore = 10
</code></pre>