View Single Post
  #2   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP
 
Posts: n/a
Default automatically format table rows

This will require modification for your particular case if you have things
other than text formfields:

Sub addrow()

'

' 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 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.Table s(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(1).Rows.Count,
1).Range.FormFields(1).Select

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True



End Sub

--
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

"Mikki" wrote in message
...
I'm using Word 2003/SP2. I'm creating a table in which all the rows are
identical - the cells within each row are formatted with form fields (text
boxes, check boxes, etc) The table also has borders, page borders, and
shading. This table will be distributed to users to fill in the blanks.
My problem is that each user will need a different number of rows and I
would
like the user to be able to automatically add new formatted rows
(including
the form fields) when they tab through the last cell in the table. By
leaving the table unlocked I can get a new row added but I don't know how
to
automatically include the form fields. Thanks for any help you can give
me!