Question : Auto Add a new row in a form in Word

I have a word form that I want to lock. At the bottom of the form I have a time line table that needs to be filled out. What I want to happen is that when a user enters into the event portion of the table I want the table to auto add a row since the user won't be able to.
Attachments:
 
 
Related Solutions: Cell Table Auto Add Row

Answer : Auto Add a new row in a form in Word

This will add a new row with new formfields. It disconnects itself from the current cell and connects it to the new last cell.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Sub NewRow()
    Dim tbl As Table
    Dim rw As Row
    Dim cl As Cell
    Dim ffld As FormField
    
    ActiveDocument.Unprotect 'password
    Set tbl = Selection.Tables(1)
    
    'remove EntryMacro from current last cell
    Set cl = Selection.Cells(1)
    Set ffld = cl.Range.FormFields(1)
    ffld.EntryMacro = ""
    
    Set rw = tbl.Rows.Add
    For Each cl In rw.Cells
        ActiveDocument.FormFields.Add cl.Range, wdFieldFormTextInput
        If cl.ColumnIndex = rw.Cells.Count Then
            Set ffld = cl.Range.FormFields(1)
            ffld.EntryMacro = "NewRow"
        End If
    Next cl
    ActiveDocument.Protect wdAllowOnlyFormFields, True ' ,password
End Sub
Random Solutions  
 
programming4us programming4us