Sirfanta
10-04-2007, 04:49 AM
I’m trying to not use selection, is there a way to add field by using range?
I want to put some field inside cells in a table.
I know that this doesn’t work (its some sort of explanation).
Sub Test()
Dim jtab As Table
Dim jRow As Row
Dim felt1 As Word.field
Dim felt2 As Word.field
Set jtab = ActiveDocument.Tables(8)
Set jRow = jtab.Range.Rows(3)
Set felt1 = Selection.Fields.Add(Range:=Selection.Range, _
Type:=wdFieldEmpty, Text:="STYLEREF Test1 \*MERGEFORMAT", _
PreserveFormatting:=True)
Set felt2 = Selection.Fields.Add(Range:=Selection.Range, _
Type:=wdFieldEmpty, Text:="STYLEREF Test2 \*MERGEFORMAT", _
PreserveFormatting:=True)
jRow.Cells(3).Range.Text = "This" & felt1 & "fun" & felt2 & "!!!"
End Sub
: pray2:
I want to put some field inside cells in a table.
I know that this doesn’t work (its some sort of explanation).
Sub Test()
Dim jtab As Table
Dim jRow As Row
Dim felt1 As Word.field
Dim felt2 As Word.field
Set jtab = ActiveDocument.Tables(8)
Set jRow = jtab.Range.Rows(3)
Set felt1 = Selection.Fields.Add(Range:=Selection.Range, _
Type:=wdFieldEmpty, Text:="STYLEREF Test1 \*MERGEFORMAT", _
PreserveFormatting:=True)
Set felt2 = Selection.Fields.Add(Range:=Selection.Range, _
Type:=wdFieldEmpty, Text:="STYLEREF Test2 \*MERGEFORMAT", _
PreserveFormatting:=True)
jRow.Cells(3).Range.Text = "This" & felt1 & "fun" & felt2 & "!!!"
End Sub
: pray2: