Can I make an adjustable table in a form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am making a form (Office 2003) where a table will adjust according to the
info the users need to fill in. Some will only need 2 or 3 rows and some may
need 50. How can I do that in a table in a form?
Thanks,
Cheryl
 
Is this a form with formfields in a protected document or something else?

--
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
 
Yes, I have other formfields in my template/form which I will send to the
users to fill in and return to me with their information. (I hope this is
what you mean - I'm a intermediate user).
Thanks
 
OK, this may do what you want:

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


End Sub

If you do not know what to do with it, see the article "What do I do with
macros sent to me by other newsgroup readers
to help me out?" at:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
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
 
Doug,
After adding the macro according to the instructions from the link you
provided, when I tried to run I got an error. It is on the 6th row
ActiveDocument.FormFields.Add
The error I receive is "Compile error: Argument not optional." It highlights
..Add
Can you help me?
Thanks,
Cheryl
 
Back
Top