Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Worsty Worsty is offline
external usenet poster
 
Posts: 3
Default add rows to Word table copying form fields

I have the following code in my MS Word 2003 form. It works great for
copying the forms fields in the table and adding the next row when
implemented from the last cell in the table row, exit event. The
problem is that I need to be able to get out of the macro and move on
to other form fields when I'm done adding rows to the current table.
This code keeps adding rows no matter what. I know it is probably
something very simple to add to the code, but can't seem to get it
just right. Any help would be appreciated:

Dim rownum As Long, i As Long, j As Long
Dim oRng As Word.Range
Dim pListArray() As String
Dim pType As String
Dim myField As FormField
Dim oTbl As Table
Dim Response

Set oTbl = Selection.Tables(1)
ActiveDocument.Unprotect
oTbl.Rows.Add
rownum = oTbl.Rows.Count
For i = 1 To oTbl.Columns.Count
Set oRng = oTbl.Cell(rownum, i).Range
oRng.Collapse wdCollapseStart
pType = oTbl.Cell(rownum - 1, i).Range.FormFields(1).Type
Select Case pType
Case 83 'Constant for a dropdown
Set myField = ActiveDocument.FormFields.Add(Range:=oRng, _
Type:=wdFieldFormDropDown)
For j = 1 To oTbl.Cell(rownum - 1, i).Range.FormFields
(1).DropDown.ListEntries.Count
ReDim Preserve pListArray(j)
pListArray(j) = oTbl.Cell(rownum - 1, i).Range.FormFields
(1).DropDown.ListEntries(j).Name
Next j
For j = 1 To UBound(pListArray)
myField.DropDown.ListEntries.Add pListArray(j)
Next j
Case 70 'Constant for a textfield
ActiveDocument.FormFields.Add Range:=oRng, _
Type:=wdFieldFormTextInput
Case 71 'Constant for a checkbox
ActiveDocument.FormFields.Add Range:=oRng, _
Type:=wdFieldFormCheckBox
End Select
Next i
oTbl.Cell(oTbl.Rows.Count, oTbl.Columns.Count).Range.FormFields
(1).ExitMacro = "Gregaddrows"
oTbl.Cell(oTbl.Rows.Count, 1).Range.FormFields(1).Select

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

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
Copying table rows into new document Wordisdrivingmeinsane Tables 1 August 28th 08 12:54 PM
Copying Rows with Form Fields Jamie Tables 2 February 15th 08 06:00 PM
Automatic copying of form fields clatters69 Microsoft Word Help 1 September 20th 06 11:37 AM
Repeating Rows with Form Fields LPS Tables 1 May 20th 06 07:41 PM
Q: Automatically adding form fields to new rows in table Richard J Tables 1 December 29th 05 04:10 PM


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