title: How do I insert a row into a table in Word using VBA Access 2007?
body: <p>I am trying to insert a row into a table in a Word document using Access 2007 VBA.  I have tried ListRows, Rows, Insert, EntireRow.Insert, etc.  I have found Microsoft's help for 2010+ but nothing that works for 2007.  I'm pretty sure its because I don't understand the syntax on how to execute the insert properly.  Below is my code, can anyone help?  My Word document has 1 table which has 1 row with 7 columns.  Thanx!</p>
  
  <pre><code>Public Sub documentBilletingReserve()
      ' Create pointers to Word Document
      Dim objWord As Word.Application
      Dim objDoc As Word.Document 'doc As Word.Document
      Dim bolOpenedWord As Boolean
  
      ' Get pointer to Word Document
      On Error Resume Next
      Set objWord = GetObject(, "Word.Application")
      If Err.Number = 429 Then
          ' If Word is not opened, open it
          Set objWord = CreateObject("Word.Application")
          bolOpenedWord = True
      End If
  
      objWord.Visible = True ' Set this to true if you want to see the document open 
      On Error GoTo 0
  
      'Create New Blank Document
      Set objDoc = objWord.Documents.Add("Z:\08_Volume Management\ACCESS\EMAILTEMPLATES\BilletingRequest.dotx") 
  
      'Create Excel Table in Word doc to populate request
      Dim currentRow As Integer
      currentRow = 2
      Dim objRange
      Dim objTable
  
      Set objRange = objDoc.Range
      'objDoc.Tables.Add objRange, intNoOfRows, intNoOfColumns
      Set objTable = objDoc.Tables(1)
      'objTable.Borders.Enable = False ' Set to true to see the borders
      'objTable.Cell(2, 1).Range.Text = "RM"
  
      ' Loop through delegates
  
      ' Pick Names Delegate Names
      Dim finishedSearch As Boolean
      Dim counterDelegate As Integer
      counterDelegate = 2
      finishedSearch = False
  
      MMRank = DLookup("[Rank]", "ModelManagers", "[ID] = " + CStr(counterDelegate))
      MMFirstName = DLookup("[FirstName]", "ModelManagers", "[ID] = " + CStr(counterDelegate))
      MMLastName = DLookup("[LastName]", "ModelManagers", "[ID] = " + CStr(counterDelegate))
  
      objTable.Cell(2, 1).Range.InsertAfter Text:="RM"
  
      ‘************************************************************
      ‘********** INSERT ROW TO TABLE IN WORD HERE
      ‘************************************************************
      Set rowNew = objTable.ListObject.ListRows.Add(AlwaysInsert:=True)
      rowNew.Range.cells(1, 1).Value = MMGender
  
      objTable.Cell(2, 1).Range.Text = CStr(currentRow - 1)
      objTable.Cell(2, 3).Range.Text = MMRank
      objTable.Cell(2, 4).Range.Text = MMFirstName + " " + MMLastName
      currentRow = currentRow + 1
      ‘************************************************************
  
      ' This will shift the focus to Word
      'objWord.Activate
  
      'Save New Document
      'On Error Resume Next
  
      Dim stringFilename As String
      stringFilename = "Z:\08_Volume Management\ACCESS\EMAILATTACHMENTS\BilletingRequest" + [VolumeName] + ".docx"
  
      'On Error Resume Next
      objDoc.SaveAs (stringFilename)
      'On Error Resume Next
  
      'On Error GoTo 0
  
      'Close and release pointers
      objDoc.Close False 'doc.Close False
      Set objDoc = Nothing
      If bolOpenedWord = True Then
          'Close Word
          objWord.Quit
      End If
  
      Set objWord = Nothing
  End Sub
  </code></pre>