All,
I need some help with a macro to add rows to a table in a locked down form. I already have a macro that works for 90% of the functionality. I am using word 2003
The desired behaviour is when the last row is tabbed through (or entered and exited), a new row is added, with all the same pre-defined dropdowns as the preceeding row. The macro I have only adds a row, but does not copy the drop downs in the table as well or save any of the cell attributes (max char, char type, ect.)
I also want to know why when I sent this document to a colleague of mine, the macro no longer worked. I sent the .doc file..is that the wrong thing to send?
Below is my code (ive spaced each line so you can clearly see line breaks)
Sub addRow()
Dim rownum As Long, i As Long
With ActiveDocument
.Unprotect
With Selection.Tables(1)
.Rows.Add
rownum = .Rows.Count
For i = 1 To .Columns.Count
ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput
Next i
.Cell(.Rows.Count, .Columns.Count).Range.FormFields(1).ExitMacro = "addRow"
.Cell(.Rows.Count, 1).Range.FormFields(1).Select
End With
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End With
End Sub
I need some help with a macro to add rows to a table in a locked down form. I already have a macro that works for 90% of the functionality. I am using word 2003
The desired behaviour is when the last row is tabbed through (or entered and exited), a new row is added, with all the same pre-defined dropdowns as the preceeding row. The macro I have only adds a row, but does not copy the drop downs in the table as well or save any of the cell attributes (max char, char type, ect.)
I also want to know why when I sent this document to a colleague of mine, the macro no longer worked. I sent the .doc file..is that the wrong thing to send?
Below is my code (ive spaced each line so you can clearly see line breaks)
Sub addRow()
Dim rownum As Long, i As Long
With ActiveDocument
.Unprotect
With Selection.Tables(1)
.Rows.Add
rownum = .Rows.Count
For i = 1 To .Columns.Count
ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput
Next i
.Cell(.Rows.Count, .Columns.Count).Range.FormFields(1).ExitMacro = "addRow"
.Cell(.Rows.Count, 1).Range.FormFields(1).Select
End With
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End With
End Sub