djburnheim
Technical User
I'm using the built in "Forms" tool in MS Word to create a report template. The template has several tables in it that could be anywhere from 1 row to 50. Rather than create 50 rows straight off I'm trying to dynamacly create rows as they are needed. The last cell in each row has a Text Form Field and I've created a macro that prompts the user to create another row which runs when the user exits the field (see below)...this bit is working but the bit I'm having trouble with is assigning the same Exit macro to the new field that is created in the new row. Any ideas would be greatly appreciated.
Code:
Sub AddComment()
Set Doc = ActiveDocument
Response = MsgBox("Add another comment?", vbYesNo, "Comments")
If Response = vbYes Then
If Doc.ProtectionType <> wdNoProtection Then Doc.Unprotect
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Doc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If
End Sub