idoo 发表于 2006-8-13 22:37:00

[讨论][求助]文字对齐方式

<P>以下是我在VBA开发时的文字录入的方法:</P>
<P>Function WZ(X0, Y0, AG1, TXT, TXTH, LAY1)<BR>'定义标注文字方式</P>
<P>On Error Resume Next<BR>Dim INP1(0 To 2) As Double<BR>INP1(0) = X0: INP1(1) = Y0: INP1(2) = 0<BR>Set OBJTXT = ThisDrawing.ModelSpace.AddText(TXT, INP1, TXTH)<BR>OBJTXT.StyleName = "DXT"<BR>OBJTXT.Layer = LAY1<BR>OBJTXT.Rotation = AG1<BR>Asc (Left(TXT, 1))<BR>If Asc(Left(TXT, 1)) &gt;= 48 And Asc(Left(TXT, 1)) &lt;= 90 Then<BR>&nbsp;&nbsp;&nbsp; XX = Len(TXT) * TXTH / 40 * SCAL * 0.71 / 4<BR>Else<BR>&nbsp;&nbsp;&nbsp; XX = (Len(TXT)) * TXTH / 40 * SCAL * 0.71 / 2<BR>End If<BR>If AG1 &lt;&gt; 0 Then<BR>&nbsp;&nbsp;&nbsp; INP1(0) = X0:&nbsp;&nbsp; INP1(1) = Y0 + XX:&nbsp; INP1(2) = 0<BR>Else<BR>&nbsp;&nbsp;&nbsp; INP1(0) = X0 + XX: INP1(1) = Y0 + TXTH / 2: INP1(2) = 0<BR>End If<BR>OBJTXT.Rotate INP1, RAG</P>
<P>End Function</P>
<P>当需要输入文字时,适用如下代码:</P>
<P>Call WZ(TKBASEX + 20.8 * SCAL, TKBASEY + 19.6 * SCAL, 3.14159 * (-0.5), "数 量", 2.5 * SCAL, "TK")</P>
<P>可是目前有一个问题:要将文字的对正方式跟改为“调整”,该怎么操作??此时该如何指定“文字对齐&nbsp; 坐标”和“位置&nbsp; 坐标”?</P>

wyj7485 发表于 2006-8-14 09:33:00

OBJTXT .Alignment = acAlignmentFit<BR>OBJTXT .TextAlignmentPoint = INP1

idoo 发表于 2006-8-14 20:34:00

<P>谢谢!依照楼上的方法,问题解决了!</P>

vladimirputin 发表于 2019-9-2 15:45:50

非常不错的代码,谢谢分享。
页: [1]
查看完整版本: [讨论][求助]文字对齐方式