AnsweredAssumed Answered

What is the variable to center align text in a macro?

Question asked by Eric Wilson on Nov 19, 2019
Latest reply on Nov 19, 2019 by Eric Wilson

I'm new at this.  I have created a macro that makes the following text but I want it to be center aligned.  It currently aligns right.



(P/N: [part number here from custom property])


Here is what I am using to make a note that says:


Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long


Sub main()


Set swApp = Application.SldWorks


Set Part = swApp.ActiveDoc
Part.FontUnderline True
Part.FontPoints 16
Part.FontUnderline False


Dim myNote As Object
Dim myAnnotation As Object
Dim myTextFormat As Object
Set myNote = Part.InsertNote("<FONT size=16PTS effect=U>ISOMETRIC VIEW" + Chr(13) + Chr(10) + _
        "<FONT effect=RU>(P/N: $PRPSHEET:""PARTNO"")")
If Not myNote Is Nothing Then
   myNote.LockPosition = False
   myNote.Angle = 0
   boolstatus = myNote.SetBalloon(0, 0)
   Set myAnnotation = myNote.GetAnnotation()
   If Not myAnnotation Is Nothing Then
      longstatus = myAnnotation.SetLeader3(swLeaderStyle_e.swNO_LEADER, 0, True, False, False, False)
      boolstatus = myAnnotation.SetPosition(0.3, 0.1, 0)


      Set myTextFormat = Part.GetUserPreferenceTextFormat(0)
      myTextFormat.Italic = False
      myTextFormat.Underline = False
      myTextFormat.Strikeout = False
      myTextFormat.Bold = False
      myTextFormat.Escapement = 0
      myTextFormat.LineSpacing = 0.001
      myTextFormat.CharHeight = 0.003175
      myTextFormat.TypeFaceName = "Century Gothic"
      myTextFormat.WidthFactor = 1
      myTextFormat.ObliqueAngle = 0
      myTextFormat.LineLength = 0
      myTextFormat.Vertical = False
      myTextFormat.BackWards = False
      myTextFormat.UpsideDown = False
      myTextFormat.CharSpacingFactor = 1
      boolstatus = myAnnotation.SetTextFormat(0, False, myTextFormat)
   End If
End If
End Sub


What is the variable to center align text?  Thanks.