S
shanbones
I am using the following macro (provided by a newsgroup poster) to try and
have a row automatically added to a table in a protected form when the field
is tabbed out of:
' To add a new row to a table containing formfields in every column
' automatically on exit from the last cell in the present last row of the
table
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
However, I received an error message when I try to run it. The := of the
following section was hightlighted and the error message says "Compile Error:
Expected: expression"
Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range,
So I altered the above line by replacing the = with a space. Now the error
hightlighting does not highlight that section but has moved to the line above
it (ActiveDocument.FormFields.Add) highlighting the .Add section and giving
me the following error message "Compile error: Argument not optional."
Any assistance that can be provided would be of great help!
shanbones
have a row automatically added to a table in a protected form when the field
is tabbed out of:
' To add a new row to a table containing formfields in every column
' automatically on exit from the last cell in the present last row of the
table
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
However, I received an error message when I try to run it. The := of the
following section was hightlighted and the error message says "Compile Error:
Expected: expression"
Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range,
So I altered the above line by replacing the = with a space. Now the error
hightlighting does not highlight that section but has moved to the line above
it (ActiveDocument.FormFields.Add) highlighting the .Add section and giving
me the following error message "Compile error: Argument not optional."
Any assistance that can be provided would be of great help!
shanbones