How do I create a form with dynamic tables?

K

KEG in Indy

I want to create a form in Word that has a table with Text Fields, drop-down
lists, date formatting, etc. but I also want to give the user of the template
the ability to add rows to the table if necessary to input more data. This
can probably be done with scripting, and I'm willing to do that, but would
like some example scripts and guidance, or, even better, a way to do it
without scripting. I want to lock the template so the users can only enter
data in the designated areas but want a "dynamic table" for part of the data.
 
D

Doug Robbins

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


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

Lori

So, is it possible to create a table in a form without macros, but can still
add/delete rows and make changes, etc.?
Thanks a million.
 
M

macropod

Hi Lori,

Not if:
.. you want the addition/deletion to occur automatically; or
.. the table is in a protected Section of the document.
 
L

Lori

Ok, thanks for the quick response.

macropod said:
Hi Lori,

Not if:
.. you want the addition/deletion to occur automatically; or
.. the table is in a protected Section of the document.

--
Cheers
macropod
[Microsoft MVP - Word]


Lori said:
So, is it possible to create a table in a form without macros, but can still
add/delete rows and make changes, etc.?
Thanks a million.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top