G
Greg Maxey
I wonder why you can add a formfield to a range set to a table cell
range, but you can't add a field to range set to a table cell range.
As the code below illustrates, to add a field to a table cell you first
have to collapse a range assigned to a table cell range:
Sub RangeTest()
Dim oRng1 As Word.Range
Dim oRng2 As Word.Range
Set oRng1 = ActiveDocument.Tables(1).Rows(1).Cells(1).Range
Set oRng2 = ActiveDocument.Tables(1).Rows(1).Cells(2).Range
ActiveDocument.FormFields.Add oRng1, wdFieldFormTextInput
On Error GoTo Err_Handler
ActiveDocument.Fields.Add oRng2, wdFieldQuote, "Test"
Exit Sub
Err_Handler:
oRng2.Collapse wdCollapseStart
Resume
End Sub
range, but you can't add a field to range set to a table cell range.
As the code below illustrates, to add a field to a table cell you first
have to collapse a range assigned to a table cell range:
Sub RangeTest()
Dim oRng1 As Word.Range
Dim oRng2 As Word.Range
Set oRng1 = ActiveDocument.Tables(1).Rows(1).Cells(1).Range
Set oRng2 = ActiveDocument.Tables(1).Rows(1).Cells(2).Range
ActiveDocument.FormFields.Add oRng1, wdFieldFormTextInput
On Error GoTo Err_Handler
ActiveDocument.Fields.Add oRng2, wdFieldQuote, "Test"
Exit Sub
Err_Handler:
oRng2.Collapse wdCollapseStart
Resume
End Sub