mycad 发表于 2013-10-22 16:58:39

请教版主、高手,多字(mtext)vba程序实现居中怎样处理?

请教版主、高手,多字(mtext)vba程序实现居中怎样处理?单行文字使用Alignment,多行文字不知怎样处理,谢谢!

mycad 发表于 2013-10-22 17:08:40

Sub Example_AttachmentPoint()
    Dim MTextObj As AcadMText
    Dim width As Double
    Dim text As String
    Dim count As Integer
    Dim attachPoint As String
    Dim corner(0 To 2) As Double
      
    corner(0) = 3#: corner(1) = 3#: corner(2) = 0#
    width = 10
    text = "Hello, World."
    ' Creates a MText object in model space
    Set MTextObj = ThisDrawing.ModelSpace.AddMText(corner, width, text)

    For count = 1 To 9
      MTextObj.AttachmentPoint = count
   
      ' Gets the attachment point of an MText object
      attachPoint = Choose(MTextObj.AttachmentPoint, "TopLeft", "TopCenter", "TopRight", "MiddleLeft", "MiddleCenter", "MiddleRight", "BottomLeft", "BottomCenter", "BottomRight")
   
      ThisDrawing.Regen True
      MsgBox "The attachment point of the MText is now: " & attachPoint, vbInformation, "AttachmentPoint Example"
    Next
End Sub

mycad 发表于 2013-10-23 10:09:58

mtxt.AttachmentPoint = AcAttachmentPoint.acAttachmentPointMiddleCenter'多行文字居中
页: [1]
查看完整版本: 请教版主、高手,多字(mtext)vba程序实现居中怎样处理?