Thread: [Solved] Adding Rows to a Table
View Single Post
 
Old 12-23-2013, 12:51 PM
SuzeG SuzeG is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Dec 2013
Location: Va Beach
Posts: 21
SuzeG is on a distinguished road
Default

That did not work.
I found this code online and adjusted it to copy three rows with contentcontrols to 3 new rows. However I cannot add this code to my document that contains many tables. This would be the 7th Table.
As a novice I am unclear how to specify that this code applies only to Table 7.

Code:
 
 Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
Dim p_oTargetRow As Word.Row
With Selection.Range
  If .Information(wdWithInTable) Then
    If .Cells(1).RowIndex = .Tables(1).Range.Cells _
                            (.Tables(1).Range.Cells.Count).RowIndex Then
      If .Cells(1).ColumnIndex = .Tables(1).Range.Cells _
                                 (.Tables(1).Range.Cells.Count).ColumnIndex Then
        If MsgBox("This is the last row/last cell." _
                & " Do  you want to ADD a new Performance Goal ROW?", _
                  vbQuestion + vbYesNo, "New Row") = vbYes Then
          InsertRowWithContent
        End If
        Set p_oTargetRow = Selection.Rows(1)
      End If
    End If
  End If
End With
End Sub
Thank you for your help.
Reply With Quote