Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying table rows into new document | Tables | |||
Copying Rows with Form Fields | Tables | |||
Automatic copying of form fields | Microsoft Word Help | |||
Repeating Rows with Form Fields | Tables | |||
Q: Automatically adding form fields to new rows in table | Tables |