J
Jamie
I am working in Word 2003.
I have a table; 5 columns, 2 rows. The first row consists of column
headings, the second row contains form fields in each column. I have an on
exit macro on the last form field that creates a new row with form fields in
each column. Two of the form fields are dates with the format of MMMM d,
yyyy. The new fields do not maintain this date format. Is there a way to
copy the formats of the form fields? Here is my coding:
Sub AddRow()
Dim rownum As Integer, i As Integer
ActiveDocument.Unprotect
ActiveDocument.Tables(1).Rows.Add
rownum = ActiveDocument.Tables(1).Rows.Count
For i = 1 To ActiveDocument.Tables(1).Columns.Count
ActiveDocument.FormFields.Add
Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range, _
Type:=wdFieldFormTextInput
Next i
ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count, _
ActiveDocument.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro =
"addrow"
ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count, _
1).Range.FormFields(1).Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub
Thanks!
I have a table; 5 columns, 2 rows. The first row consists of column
headings, the second row contains form fields in each column. I have an on
exit macro on the last form field that creates a new row with form fields in
each column. Two of the form fields are dates with the format of MMMM d,
yyyy. The new fields do not maintain this date format. Is there a way to
copy the formats of the form fields? Here is my coding:
Sub AddRow()
Dim rownum As Integer, i As Integer
ActiveDocument.Unprotect
ActiveDocument.Tables(1).Rows.Add
rownum = ActiveDocument.Tables(1).Rows.Count
For i = 1 To ActiveDocument.Tables(1).Columns.Count
ActiveDocument.FormFields.Add
Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range, _
Type:=wdFieldFormTextInput
Next i
ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count, _
ActiveDocument.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro =
"addrow"
ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count, _
1).Range.FormFields(1).Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub
Thanks!