I am trying to write a macro that will go into my drawings and edit an existing text note. This annotation is not attached to any drawing views; When using the macro recorder to try and see what API calls are used, the editing portion is not recorded. For example, in the following code generated from the Macro Recorder, I first created a text note "This is a text note". I then reselected the text note and changed its value to "This is a sample text note". However, this edit is not recorded in the macro. I was wondering if any of you out there know if there is an API call that I can use to edit the text note's value after it has already been created.
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
Dim myNote As Object
Dim myAnnotation As Object
Dim myTextFormat As Object
Set myNote = Part.InsertNote("This is a text note")
If Not myNote Is Nothing Then
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, True)
boolstatus = myAnnotation.SetPosition(0.1791476075924, 0.2016534633028, 0)
boolstatus = myAnnotation.SetTextFormat(0, True, myTextFormat)
End If
End If
Part.ClearSelection2 True
Part.WindowRedraw
boolstatus = Part.Extension.SelectByID2("DetailItem38@Sheet1", "NOTE", 0.2090247176842, 0.1981793807339, 0, False, 0, Nothing, 0)
'I believe the API call to edit the text of the note to "This is a sample text note" should appear at this point?
Part.ClearSelection2 True
End Sub
The results of the macro are shown below