Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Jay Freedman
 
Posts: n/a
Default

Stikfa wrote:
I have a table setup withtwo columns to insert a new row when you tab
through the las column. Using this code:
With Selection
If .Information(wdWithInTable) Then
.Tables(1).Rows.Last.Select
.InsertRowsBelow 1
End If
End With

And all is good, except that I would like to create the new row with
a 'Text Form Field' in each column.

The last row of my table already has the form fields. So is it
possible to, when inserting the new row, to have it also insert the
form fields or maybe have it copy the filds from the previouse row?

thx


Hi Stikfa,

The same macro that adds the row can also insert new fields in it. The
following code is a bit more complicated than what you showed, but it has
two main advantages: (1) it doesn't move the Selection, which corresponds to
the insertion point in the document, and (2) it will insert the right number
of fields, regardless of how many columns your table has.

Dim myTable As Table
Dim myRow As Row
Dim ColNum As Long

If Not Selection.Information(wdWithInTable) Then
Exit Sub ' no table; don't do any more
End If

' make an onject that represents the table
Set myTable = Selection.Tables(1)

' add a row to the bottom of the table
' and make an object that represents the row
Set myRow = myTable.Rows.Add

' use a loop to insert a form field into
' each cell in the new row
For ColNum = 1 To myTable.Columns.Count
ActiveDocument.FormFields.Add _
Range:=myRow.Cells(ColNum).Range, _
Type:=wdFieldFormTextInput
Next ColNum

' clean up
Set myRow = Nothing
Set myTable = Nothing

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org


 
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
Enter data in 1 text form field & have multiple locations fill Lee Microsoft Word Help 1 March 16th 05 10:56 PM
How do I make "tab" go from form field to form field? DLS Microsoft Word Help 2 February 16th 05 07:44 PM
Form Field (defining and associating a bookmark with it) Judi Microsoft Word Help 2 February 11th 05 09:53 PM
Text Form Field Ref in Footer Won't Update on Screen StarWine Microsoft Word Help 3 December 6th 04 06:17 PM
Form Field Automation Mitch Microsoft Word Help 2 November 29th 04 07:29 PM


All times are GMT +1. The time now is 06:43 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"