About Creating Multiline Text (VBA/ActiveX)

You can create a multiline text object (MText object) by using the AddMText method.

The AddMText method requires three values as input: the text string, the insertion point in the drawing to place the text, and the width of the text bounding box.

The text string is the actual text to be displayed. Unicode, control code, and special characters are accepted. The insertion point is a variant array containing three doubles representing the 3D WCS coordinate in the drawing to place the text. The width of the text is a positive number representing the width of the bounding box for the text. Width is measured in the current units.

After the MText object is created, you can apply the text height, justification, rotation angle, and style to the MText object, or apply character formatting to selected characters.

To Create Multiline Text

The following code creates an MText object in model space, at the coordinate (2, 2, 0).

Sub Ch4_CreateMText()
  Dim mtextObj As AcadMText
  Dim insertPoint(0 To 2) As Double
  Dim width As Double
  Dim textString As String

  insertPoint(0) = 2
  insertPoint(1) = 2
  insertPoint(2) = 0
  width = 4
  textString = "This is a text string for the mtext object."

  ' Create a text Object in model space
  Set mtextObj = ThisDrawing.ModelSpace.AddMText(insertPoint, width, textString)
  ZoomAll
End Sub