Thread: [Solved] Code to add new row in table
View Single Post
 
Old 09-08-2015, 08:17 AM
ksigcajun ksigcajun is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: May 2014
Posts: 76
ksigcajun is on a distinguished road
Default Code to add new row in table

I initially wanted this code to prompt for the addition of a new row in a table. What the easiest way to change the code where it only prompts in one specific table and not every table in my word document.

Do I need to name the specific table somehow first?

Thanks for the help!

PHP Code:
Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
With Selection.Range
  
If .Information(wdWithInTableThen
    
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(" Do you want to add a new row to the table?"_
                  vbQuestion 
vbYesNo"Question") = vbYes Then
          InsertRowWithContent
        End 
If
        
Set p_oTargetRow Selection.Rows(1)
      
End If
    
End If
  
End If
End With
End Sub 
Reply With Quote