Reply
 
Thread Tools Display Modes
  #1   Report Post  
KLSiegel
 
Posts: n/a
Default Using VBA to Add Table Row to Form Table

I have a form, with fields, for collecting input from users. In the middle of
the form is a table, with two text fields and a column that has clickable
check boxes. The table has four "content" rows plus a heading. The users
inform me that they may need to add rows to this table, because for some
instances, they have more information to record.

So how do I set things up such that if they need/want to, they can add rows,
without unprotecting the form (and thus disabling the checkboxes, which they
like having)? I'm guessing I'll need to create a macro of some kind, and make
that an Exit macro on the last field or cell in the table. Alternately,
possibly I could create a button of some kind.

Any helpful suggestions?
  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

Here's one way:

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

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"KLSiegel" wrote in message
...
I have a form, with fields, for collecting input from users. In the middle
of
the form is a table, with two text fields and a column that has clickable
check boxes. The table has four "content" rows plus a heading. The users
inform me that they may need to add rows to this table, because for some
instances, they have more information to record.

So how do I set things up such that if they need/want to, they can add
rows,
without unprotecting the form (and thus disabling the checkboxes, which
they
like having)? I'm guessing I'll need to create a macro of some kind, and
make
that an Exit macro on the last field or cell in the table. Alternately,
possibly I could create a button of some kind.

Any helpful suggestions?



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Making a Form :: Line Borders / Table Cells with Flowing Text John Microsoft Word Help 1 January 2nd 05 02:42 PM
Row height problem with table in table Stephanie T. Tables 0 November 23rd 04 03:35 PM
table caption numbering scottkinsey Tables 1 November 11th 04 11:47 AM
Repeating Table headings with "Continued" scottkinsey Tables 4 November 10th 04 06:04 PM
Getting the format of a table Kind writer/user/programmer Tables 0 October 29th 04 02:52 AM


All times are GMT +1. The time now is 08:26 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"