Reply
 
Thread Tools Display Modes
  #1   Report Post  
FredEp57
 
Posts: n/a
Default forms and tables

Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in each cell.
I need to have the table grow dynamically and have the text field in each new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F
  #2   Report Post  
Jezebel
 
Posts: n/a
Default

Yes, you're approaching this the wrong way. Not sure what the right way is
without knowing what you really need to end up with, but Word forms can't
spawn new fields dynamically, in a table or anywhere else.


"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in each
cell.
I need to have the table grow dynamically and have the text field in each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F



  #3   Report Post  
Doug Robbins
 
Posts: n/a
Default

' 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.Table s(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(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
"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in each
cell.
I need to have the table grow dynamically and have the text field in each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F



  #4   Report Post  
Doug Robbins
 
Posts: n/a
Default

It got through and I now realise that I posted an answer to it yesterday.

--
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
"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in each
cell.
I need to have the table grow dynamically and have the text field in each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F



  #5   Report Post  
FredEp57
 
Posts: n/a
Default

Doug,

Thanks. However my skills at VBA are very poor. Can I just cut and paste
this into the VBA editor? I tried and get compilation errors after the
ActiveDocument.FormFields.Add line.

Let me now how to put this in the document.

F

"Doug Robbins" wrote:

' 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.Table s(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(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
"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in each
cell.
I need to have the table grow dynamically and have the text field in each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F






  #6   Report Post  
FredEp57
 
Posts: n/a
Default

Doug,

FInally got this to "work". However, I have a couple of problems.
1 - can you explain each line (what it does and/or is doing) please?
2 - I have a lot of different tables so need to access the first and third.
Changing (globally) from (1) to (3) for the third causes an error.
3 - when I use the code on exit, the next row does not add any fields. Am I
missing something?

Thanks again for you invaluable help.

F

"Doug Robbins" wrote:

' 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.Table s(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(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
"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in each
cell.
I need to have the table grow dynamically and have the text field in each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F




  #7   Report Post  
Doug Robbins
 
Posts: n/a
Default

Replace

ActiveDocument.Tables(1)

with

Selection.Tables(1)

wherever the former occurs.

The lines of code a pretty self explanatory.

The only other thing that I would add is that the macro needs to be named
Sub AddRow(). That was omitted from the code as pasted.

--
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
"FredEp57" wrote in message
...
Doug,

FInally got this to "work". However, I have a couple of problems.
1 - can you explain each line (what it does and/or is doing) please?
2 - I have a lot of different tables so need to access the first and
third.
Changing (globally) from (1) to (3) for the third causes an error.
3 - when I use the code on exit, the next row does not add any fields. Am
I
missing something?

Thanks again for you invaluable help.

F

"Doug Robbins" wrote:

' 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.Table s(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(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
"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in each
cell.
I need to have the table grow dynamically and have the text field in
each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F






  #8   Report Post  
FredEp57
 
Posts: n/a
Default

Doug,

Again, thanks. I am trying to improve my skills and your tips have helped
immensely.

I would ask one more part. I have a table I built. Some of the cells have
textboxes and some have drop downs. How can I make a new row with the same
things in it?

Example, if I have a table with three cells and two have text and one has a
drop down with 5 choices. I need to make an exact copy of the upper row into
this new row. I can't figure out how to get the choices and drop down into
the table.

I can't find much on explaining the different keywords.

Again, Thanks much!!!
F

"Doug Robbins" wrote:

Replace

ActiveDocument.Tables(1)

with

Selection.Tables(1)

wherever the former occurs.

The lines of code a pretty self explanatory.

The only other thing that I would add is that the macro needs to be named
Sub AddRow(). That was omitted from the code as pasted.

--
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
"FredEp57" wrote in message
...
Doug,

FInally got this to "work". However, I have a couple of problems.
1 - can you explain each line (what it does and/or is doing) please?
2 - I have a lot of different tables so need to access the first and
third.
Changing (globally) from (1) to (3) for the third causes an error.
3 - when I use the code on exit, the next row does not add any fields. Am
I
missing something?

Thanks again for you invaluable help.

F

"Doug Robbins" wrote:

' 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.Table s(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(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
"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in each
cell.
I need to have the table grow dynamically and have the text field in
each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F






  #9   Report Post  
Doug Robbins
 
Posts: n/a
Default

It's all there in the Visual Basic Help file.

e.g.

Returns a DropDown object that represents a drop-down form field. Read-only.

Remarks
If the DropDown property is applied to a FormField object that isn't a
drop-down form field, the property won't fail, but the Valid property for
the returned object will be False.

Example
This example displays the text of the item selected in the drop-down form
field named "Colors."

Dim ffDrop As FormField

Set ffDrop = ActiveDocument.FormFields("Colors").DropDown

MsgBox ffDrop.ListEntries(ffDrop.Value).Name
This example adds "Seattle" to the drop-down form field named "Places" in
Form.doc.

With Documents("Form.doc").FormFields("Places") _
.DropDown.ListEntries
.Add Name:="Seattle"
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
"FredEp57" wrote in message
...
Doug,

Again, thanks. I am trying to improve my skills and your tips have helped
immensely.

I would ask one more part. I have a table I built. Some of the cells
have
textboxes and some have drop downs. How can I make a new row with the
same
things in it?

Example, if I have a table with three cells and two have text and one has
a
drop down with 5 choices. I need to make an exact copy of the upper row
into
this new row. I can't figure out how to get the choices and drop down
into
the table.

I can't find much on explaining the different keywords.

Again, Thanks much!!!
F

"Doug Robbins" wrote:

Replace

ActiveDocument.Tables(1)

with

Selection.Tables(1)

wherever the former occurs.

The lines of code a pretty self explanatory.

The only other thing that I would add is that the macro needs to be named
Sub AddRow(). That was omitted from the code as pasted.

--
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
"FredEp57" wrote in message
...
Doug,

FInally got this to "work". However, I have a couple of problems.
1 - can you explain each line (what it does and/or is doing) please?
2 - I have a lot of different tables so need to access the first and
third.
Changing (globally) from (1) to (3) for the third causes an error.
3 - when I use the code on exit, the next row does not add any fields.
Am
I
missing something?

Thanks again for you invaluable help.

F

"Doug Robbins" wrote:

' 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.Table s(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro
=
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(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
"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in
each
cell.
I need to have the table grow dynamically and have the text field in
each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F








  #10   Report Post  
FredEp57
 
Posts: n/a
Default

Doug,

Thanks for this. However, now I get a very strange result.

I changed all the occurances per your instructions below. Now, however, for
some reason I get a dropdown field ALONG with the text input field in my
form. Can you explain this?

Thanks
F

"Doug Robbins" wrote:

Replace

ActiveDocument.Tables(1)

with

Selection.Tables(1)

wherever the former occurs.

The lines of code a pretty self explanatory.

The only other thing that I would add is that the macro needs to be named
Sub AddRow(). That was omitted from the code as pasted.

--
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
"FredEp57" wrote in message
...
Doug,

FInally got this to "work". However, I have a couple of problems.
1 - can you explain each line (what it does and/or is doing) please?
2 - I have a lot of different tables so need to access the first and
third.
Changing (globally) from (1) to (3) for the third causes an error.
3 - when I use the code on exit, the next row does not add any fields. Am
I
missing something?

Thanks again for you invaluable help.

F

"Doug Robbins" wrote:

' 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.Table s(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(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
"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in each
cell.
I need to have the table grow dynamically and have the text field in
each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F








  #11   Report Post  
Doug Robbins
 
Posts: n/a
Default

Show us the final code.

--
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
"FredEp57" wrote in message
...
Doug,

Thanks for this. However, now I get a very strange result.

I changed all the occurances per your instructions below. Now, however,
for
some reason I get a dropdown field ALONG with the text input field in my
form. Can you explain this?

Thanks
F

"Doug Robbins" wrote:

Replace

ActiveDocument.Tables(1)

with

Selection.Tables(1)

wherever the former occurs.

The lines of code a pretty self explanatory.

The only other thing that I would add is that the macro needs to be named
Sub AddRow(). That was omitted from the code as pasted.

--
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
"FredEp57" wrote in message
...
Doug,

FInally got this to "work". However, I have a couple of problems.
1 - can you explain each line (what it does and/or is doing) please?
2 - I have a lot of different tables so need to access the first and
third.
Changing (globally) from (1) to (3) for the third causes an error.
3 - when I use the code on exit, the next row does not add any fields.
Am
I
missing something?

Thanks again for you invaluable help.

F

"Doug Robbins" wrote:

' 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.Table s(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro
=
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(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
"FredEp57" wrote in message
...
Not sure if the first one got through so I am asking again.

I want to have a table in my form. The table has text fields in
each
cell.
I need to have the table grow dynamically and have the text field in
each
new
row/cell.

Can this be done? Or am I approaching this the wrong way?

Thanks
F








Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms and tables FredEp57 Tables 1 June 28th 05 10:30 PM
Automated forms JT Microsoft Word Help 1 June 16th 05 05:56 PM
printing empty text fields on word forms moombi Microsoft Word Help 1 June 10th 05 08:16 AM
Word Forms Kristy Microsoft Word Help 1 April 29th 05 05:45 PM
Lines in forms to type on Kim K Microsoft Word Help 1 February 28th 05 06:04 PM


All times are GMT +1. The time now is 01:27 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"