Tables in Protected Documents

E

Ed

How do I allow people to expand a table in a protected document that I
created in Word 2003?
 
J

Jean-Guy Marcil

Ed said:
How do I allow people to expand a table in a protected document that I
created in Word 2003?

Do you mean expand a row in a table (so its height is increased and users
can add text to that row) or expand the table by adding rows to it (With
formfields so users can write in those new rows)?
 
E

Ed

Yes. Some users will need to increase the height of the table in order to add
additional lines of information into the table.
 
D

Doug Robbins - Word MVP

Assuming that the users are wanting to increase the height of the table by
adding additional rows and that in those rows, it will be necessary to have
formfields, you will need something like the following macro run on exit
from the last formfield in the last row.

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

This macro was set up for a 5 column table, with text formfields in the
first three cells of each row and dropdown formfields in the fourth and
fifth cells. You will need to modify it to suit your requirements.

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