TextString Property (ActiveX)

Specifies the text string for the entity.

Supported platforms: Windows only

Signature

VBA:

object.TextString
object

Type: Attribute, AttributeReference, GeoPositionMarker, MLeader, MLeaderStyle, MText, Text, Tolerance

The objects this property applies to.

Property Value

Read-only: No

Type: String

The maximum length is 256 characters.

Remarks

AttributeReference: This is equivalent to the value of the attribute in AutoCAD.

GeoPositionMarker, MText: The text string may contain format codes. You can underline, add a line over text, and create stacked text. You can also change color, font, and text height. You can change the spaces between text characters or increase the width of the characters themselves. To apply formatting, or parse existing text strings for their formatting.

Examples

VBA:

Sub Example_TextString()
    ' This example creates a text object in model space.
    ' It then returns the text string for that 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 = "Hello, World."
    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.textString
    MsgBox "The TextString property equals: " & text, vbInformation, "TextString Example"
        
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_TextString()
    ;; This example creates a text object in model space.
    ;; It then returns the text string for that object.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the text object
    (setq insertionPoint (vlax-3d-point 2 2 0)
          textString "Hello, World."
          height 0.5)
    
    ;; Create the text object in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq textObj (vla-AddText modelSpace textString insertionPoint height))
    (vla-ZoomAll acadObj)
    
    ;; Return the current text string for the object
    (setq text (vla-get-TextString textObj))
    (alert (strcat "The TextString property equals: " text))
)