Why use this code to set text content of balloon incorrecttly ?

Hi All,

when I use these code the set the text content of the balloons to be the component name where it attached, it could not set the component name one to one, but set all the text of balloons to be 1 same component.

Any guys can point out what 's wrong about it ?

pls check my code and video to know the detal.

thanks a lot

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swSelMgr                As SldWorks.SelectionMgr

    Dim swSelObj                As Object

    Dim swAnn                   As SldWorks.Annotation

    Dim vAttEntTypeArr          As Variant

    Dim vAttEntArr              As Variant

    Dim i                       As Long

    Dim swEnt As SldWorks.Entity

    Dim swComp As SldWorks.Component2

    Dim bRet As Boolean

                   

   

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

   

    Debug.Print swSelMgr.GetSelectedObjectCount

   

    Dim j As Integer

   

    For j = 1 To swSelMgr.GetSelectedObjectCount

        

   

        If swSelMgr.GetSelectedObjectType3(j, -1) = swSelNOTES Then

            Set swSelObj = swSelMgr.GetSelectedObject6(j, -1)

            Set swAnn = swSelObj.GetAnnotation

            Debug.Print "AnnName              = " & swAnn.GetName

            vAttEntArr = swAnn.GetAttachedEntities3

            Dim CompName As String

            Dim SetAnnName As Boolean

            Dim swModelDocExt As SldWorks.ModelDocExtension

            Dim swNote As SldWorks.Note

           

            Set swEnt = vAttEntArr(0)

            Set swComp = swEnt.GetComponent

            CompName = swComp.Name2

           

            Set swModelDocExt = swModel.Extension

            Set swNote = swSelObj

           

          'why this code set all the balloons to be 1 same Component name ?

            Set swNote = swModelDocExt.EditBalloonProperties2(swBalloonStyle_e.swBS_Circular, swBF_3Chars, swBalloonTextContent_e.swBalloonTextCustom, CompName, swBalloonTextCustom, " ", 0, True, 1, "X", 0.001)

           

        End If

       

    Next j

End Sub

Regards

Vincent

SolidworksApi macros