VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using VBA to create formatted MText

1 REPLY 1
SOLVED
Reply
Message 1 of 2
kasperwuyts
3706 Views, 1 Reply

Using VBA to create formatted MText

Hello everyone,

 

Is it possible to create bulleted/numbered text using VBA? I assume all I need to know is the correct syntax for the text string.

I can usually figure out Autocad text markup syntax by simply creating the text I want in regular Autocad; then hovering over the 'contents'-property in the properties pallette. But for numbered text, somewhere on the line a square □ symbol or something similar is added, which is a symbol I am unable to use in the VBA editor.

 

As an example, to create this text:

 

  1. wowee
  2. zowee

 

the code looks like this:

\pxi-3,l3,t3;1.wowee\P2.zowee

 

 

Also, is there any good resource on Autocad text code syntax in general?

 

 


Best regards
Kasper Wuyts
_______________________________________________________________________________
If this post solves your problem, clicking the 'accept as solution' button would be greatly appreciated.
1 REPLY 1
Message 2 of 2
kasperwuyts
in reply to: kasperwuyts

I have solved this issue. In case anyone should have the same problem for numbered text. Use the vbTab constant to add a tab to a string. This seems to have been the missing symbol, indicated by the square. To draw the example in my opening post, the code should look like this:

 

Sub DrawNumberedText()


Dim mtextObj As AcadMText
Dim insertPoint As Variant
Dim textString As String
Dim width As Double

insertPoint = ThisDrawing.Utility.GetPoint(, "Specify insertion point")
width = 100
textString = "1." & vbTab & "wowee\P2." & vbTab & "zowee"

Set mtextObj = ThisDrawing.ModelSpace.AddMText(insertPoint, width, textString)

End Sub

 

 

 

I still don't know a good resource for text syntax in Autocad or what it is based on, so many kudos still to be had for people who suggest some good sources.


Best regards
Kasper Wuyts
_______________________________________________________________________________
If this post solves your problem, clicking the 'accept as solution' button would be greatly appreciated.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost