Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linewidth in VBA

Status
Not open for further replies.

embee

Programmer
Oct 17, 2002
3
NL
Im accessing a DBASE-IV database and want the data to be inserted in a drawing. The problem i have is the width of the text. With the command modelspace.addtext I can only adjust the height and with .modelspace.mtext i can only modify the textbox. How do I modify the width of inserted text.
 
Hi embee

Do you mean the width of the bounding box that the text will fit to or the width-factor of the selected text?

If you mean the latter, here's a few tips and some example code. If you mean the width of the bounding box, I will research it and let you - I haven't touched much on that as yet!
When you enter the line of code (as an example):

Code:
Dim string1 As AcadMText
Set string1 = ThisDrawing.ModelSpace.AddMText.......

...it displays this tooltip text:

Code:
AddMtext
(insertion point, width as double, text as string)
Code:
as AcadMText

...So enter your text width after the insertion point, for an example:

Code:
Dim string1 As AcadMText
Dim centrex(0 to 2) As Double
' The insertion point..
' Set insertion point (replace xxx with x,y,z coordinates)..

Code:
centrex(0) = xxx: centrex(1) = xxx: centrex(2) = xxx
' Draw the MText..
Code:
Set string1 = ThisDrawing.ModelSpace.AddMText(centrex, 1.8, "Hello")

....so in this example the width factor is 1.8..

I hope this helps..

Cheers,

Renegade..
 
Thanks for replying, but your tip doesn't work for me.
I inserted text and Autocad makes it some kind of default.
I need the textproperty width to be 0.65 instead of this default.
The MText makes a box with the size x.xx but fits all text into that box (ie. stretching it)
I'm searching for something like:
With dwg.ActiveText
.width = 0.55
.height = 2.65
End With
but this doesn't work and neither does changing the textstyle or updating text or the drawing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top