Word 2003 Tables and Forms

R

Ranger Rick

Dear Expert,
I'm creating a form in Word that includes a table whose number of rows
depends on the number of entries each form-filler-outer has to enter. I can
create a table with 100 rows and all the correct fields, to cover all
contingencies, but most of the end-users will need between 5-10, and a
100-row table will really be ugly if it's 99% empty.

How do I get my form table to add a row once the last available row is
filled in?

Problem: When I protect the doc for form filling, the user cannot add more
rows herself. If I let people unprotect it, my form will get all messed up!

Thanks.
 
G

Graham Mayor

If it is a simple table ie no split/merged rows/columns then the following
macro run on exit from the last form field in the table will give you a new
row containing the fields in the last row c/w the option to insert a new
row -

Sub AddARow()
Dim i As Integer
Dim bProtected As Boolean
Dim sNewRow As String
Dim oFld As FormFields


sNewRow = InputBox("Insert New Row", "New Row", "No")
If Left(UCase(sNewRow), 1) <> "N" Then
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
With Selection
.SelectRow
.Copy
.Paste
.SelectRow
Set oFld = Selection.Range.FormFields
For i = 1 To oFld.Count
If oFld(i).DropDown = False Then
oFld(i).Result = ""
End If
Next
End With
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End If
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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