PDA

View Full Version : Justifying text in VBA



Tyke
24th Aug 2010, 09:50 am
Hi,

I am having a problem justifying text that I create in a VBA routine. When I use this code:


If ThisDrawing.ActiveSpace = acModelSpace Then
Set txtPNum = ThisDrawing.ModelSpace.AddText(strPNum, varPNumIns, dblTHeight)
Else
Set txtPNum = ThisDrawing.PaperSpace.AddText(strPNum, varPNumIns, dblTHeight)
End If

txtPNum.Alignment = acAlignmentRight
txtPNum.Update

The text is inserted at 0,0,0
If I comment out the alignment line the text is inserted in the expected position.

I also have some MText that I insert and I can't seem to find a method to set its alignment. In the AutoCAD Properties window there is an alignment property. :-(

Has anyone else encounted these problems and does anyone see what I'm doing wrong?

dbroada
24th Aug 2010, 10:11 am
does this thread help?
http://www.cadtutor.net/forum/showthread.php?41740-position-text-with-VBA

Tyke
24th Aug 2010, 10:37 am
Dave,
That works a treat for the text. Any ideas on the MText, it's not that important, but it's just bugging me.

Many thanks.

dbroada
24th Aug 2010, 10:47 am
sorry but I've (I@ve) never used MTEXT in VBA.

Tyke
24th Aug 2010, 10:54 am
Thats ok.
Many thanks for your help.