Help creatng word form

D

Deus DNE

Sorry for cross post!!!

HI,

Ive been asked to add to a word form that gathers info.

Basically they want a field that when you input a number into it, the pages
has that number of further fields appear on it!

It also needs to change the number of fields below it if you change the
number in the field!

I was ok with this until they asked this. If this is a bad/complex idea,
then i may get away with a button that when clicked adds a new field to the
end of the form!!

Any ideas gratefully recieved.

TIA

Gareth Wailes
DWP IT Support
 
D

Doug Robbins - Word MVP

Bad idea, but here is a macro that when run on exit from the last formfield
in the last row of a table will add another row to the table, inserting
formfields into the cells. In this case, there are 5 columns in the table
and text formfields are added to the first three cells and dropdown
formfields are added to the final two. You may get some ideas from this.

Dim rownum As Integer, i As Integer
With ActiveDocument
.Unprotect
.Tables(1).Rows.Add
rownum = .Tables(1).Rows.Count
For i = 1 To 3
.FormFields.Add Range:=.Tables(1).Cell(rownum, i).Range,
Type:=wdFieldFormTextInput
Next i
.FormFields.Add Range:=.Tables(1).Cell(rownum, 4).Range,
Type:=wdFieldFormDropDown
With .Tables(1).Cell(rownum, 4).Range.FormFields(1).DropDown.ListEntries
.Add "Item1"
.Add "Item2"
.Add "Item3"
.Add "Item4"
.Add "Item5"
End With
.FormFields.Add Range:=.Tables(1).Cell(rownum, 5).Range,
Type:=wdFieldFormDropDown
With .Tables(1).Cell(rownum, 5).Range.FormFields(1).DropDown.ListEntries
.Add "ItemA"
.Add "ItemB"
.Add "ItemC"
.Add "ItemD"
.Add "ItemE"
End With
.Tables(1).Cell(rownum, 5).Range.FormFields(1).ExitMacro = "addrow"
.Tables(1).Cell(rownum, 1).Range.FormFields(1).Select
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End With


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

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