View Single Post
  #2   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP on news.microsoft.com Doug Robbins - Word MVP on news.microsoft.com is offline
external usenet poster
 
Posts: 407
Default Tables in Word - Adding rows to forms

Here's a macro that does that, showing how to deal with varying types of
formfields in the row:

' Macro created 02/02/03 by Doug Robbins
' 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 Long, i As Long
Dim Response
Response = MsgBox("Do you need to add another row to the table?", _
vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row")
If Response = vbYes Then ' User chose Yes.
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
Else ' User chose No.
Exit Sub
End If


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"CSC" wrote in message
...
I'm creating a form with a table and would like to be able to add rows to
the
protected form. The saved form would have one or two rows, and the user
could add as many rows as needed to the table. Does anyone know how to do
this?