Hi,
>I've tried multiple ways of adding the merge field
so have I.
The special difficulty was, that there is no trace
of a mergefield at all in your code.
I can't recall, all that went wrong.
Whether its my fault or whether there are unrecovered bugs.
Finally, I arrived at this,
but I wonder what it could be good for.
Sub Macro9()
Dim rngTmp As Range
Set rngTmp = ActiveDocument.Tables(1).Rows(1).Cells(2).Range
ActiveDocument.FormFields.Add _
Range:=rngTmp, Type:=wdFieldFormTextInput
With ActiveDocument.FormFields
.Item(.Count).Result = "xxx"
End With
End Sub
Creating a new formfield-object and setting its result failed.

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Greg Maxey - 05 Dec 2006 13:43 GMT
Helmut,
You might find this interesting:
Sub RangeEffects()
Dim oRng1 As Range
Dim oRng2 As Range
Set oRng1 = ActiveDocument.Tables(1).Rows(1).Cells(1).Range
Set oRng2 = ActiveDocument.Tables(1).Rows(1).Cells(2).Range
oRng1.Collapse wdCollapseStart
With ActiveDocument
'Next line fails if oRng1 is not collapsed
.Fields.Add oRng1, wdFieldEmpty, "MERGEFIELD TESTMERGER"
'Next line runs without error with range expanded
.FormFields.Add oRng2, wdFieldFormTextInput
.FormFields(1).Result = "XXX"
End With
'Here is something else odd
Set oRng1 = ActiveDocument.Tables(1).Rows(1).Cells(3).Range
With ActiveDocument
'.Fields.Add oRng1, does not generate an intellisense dropdown of
available fields
'.FormFields.Add oRng2, does generate an intellisense dropdown.
'all field types are listed. So you can
construct
'the following line with intellisense:
On Error Resume Next
.FormFields.Add oRng1, wdFieldEmpty
'Which understandably fails with a RTE 9, subscript out of range
If Err.Number = 9 Then
MsgBox "RTE " & Err.Number & " " & Err.Description
Err.Clear
End If
'But this line that runs as expected can't be constructed using
intellisense!!
.Fields.Add oRng1, wdFieldEmpty, "MergeField TestMerger"
End With
End Sub
> Hi,
>
[quoted text clipped - 29 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
First you can not add a field to the range of a cell. You have to
collapse the range so that it is merely "in" the cell. Secondly, are
you sure you want a "FormField" and not merely a Merge field?
Sub Test()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Tables(1).Rows(1).Cells(2).Range
oRng.Collapse wdCollapseStart
ActiveDocument.Fields.Add oRng, Type:=wdFieldEmpty, Text:="Mergefield
TESTMERGER"
End Sub
> I'm having issues inserting a wdFieldFormTextInput into a word table
> cell. I create the table with a macro which works perfectly. I then
[quoted text clipped - 23 lines]
> I get the generic "Run-time error '4605': This command is not
> available" error message when trying to run the above.