In order to create Text as field, you need to know the field code to link the text string to different values froom the other (linked) entity. You can see "Field Exproession" at the bottom of the "Field" dialog box. For example, in the case liking a text entity to another text entity's TextString, the code is
"%<\AcObjProp Object(%<\_ObjId 1094833920>%).TextString>%", where the "ObjId" number needs to be replaces dynamically in the VBA code.
To create an AcadText as field, see VBA document's example. You can open VBA Editor in AutoCAD, open Object Browser, find AcadText on the left and find FieldCode() method on the right, click "?" button on top to open VBA document's code example. Here is quoted in the document:
Sub Example_FieldCode()
' This example creates a text object in model space.
' It then returns the field code string for the object.
Dim textObj As AcadText
Dim text As String
Dim insertionPoint(0 To 2) As Double
Dim height As Double
' Define the text object
text = "%<\AcVar Date \f ""M/d/yyyy""%>%"
insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0
height = 0.5
' Create the text object in model space
Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height)
ZoomAll
' Return the current text string for the object
text = textObj.FieldCode
MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example"
End Sub
Here is code sample I wrote, which ask user to select an existing Text entity (to be lined to), and then create a new Text entity that links to the previously selected text entity:
Private Const TEXT_STRING_FIELD_CODE As String = _
"%<\AcObjProp Object(%<\_ObjId ?>%).TextString>%"
Public Sub CreateLinkedText()
Dim txtEnt As AcadText
Set txtEnt = SelectTextEntity()
If txtEnt Is Nothing Then Exit Sub
Dim code As String
code = Replace(TEXT_STRING_FIELD_CODE, "?", CStr(txtEnt.ObjectID))
Dim insertionPt As Variant
insertionPt = PickPoint()
If VarType(insertionPt) = vbEmpty Then Exit Sub
Dim txt As AcadEntity
Set txt = ThisDrawing.ModelSpace.AddText(code, insertionPt, 1#)
txt.Update
ThisDrawing.Application.ZoomExtents
End Sub
Private Function SelectTextEntity() As AcadText
Dim ent As AcadEntity
Dim pt As Variant
On Error Resume Next
ThisDrawing.Utility.GetEntity ent, pt, vbCr & "Select a Text entity to link:"
If Not ent Is Nothing Then
If TypeOf ent Is AcadText Then
Set SelectTextEntity = ent
Exit Function
End If
End If
ThisDrawing.Utility.Prompt vbCr & "Invalid/cancelled picking." & vbCr
Set SelectTextEntity = Nothing
End Function
Private Function PickPoint() As Variant
Dim pt As Variant
On Error Resume Next
pt = ThisDrawing.Utility.GetPoint(, vbCr & "Pick linked text location:")
PickPoint = pt
End Function
As for linking Table cells to other existing text entities, you would do
1. For each table cell, identify text entity to be linked. (user picking, or based on its layer, location, text string...);
2. Once the target text is identified, compose the link code (similar as I did: replace "?" in the string constant with target text's ObjectId value);
3. Create cell content as a text as the sample code showed here (or as MText, which can be set to entirely as field, or portion of it as field)