Need Help with EditBalloonProperties2

I’m writing a macro that iterates through a drawing and changes the style of BOM Balloons, but It errors with “Object or variable With block variable not set.”

Here’s the relevent code:

For j = 0 To UBound(swAnnotations)
    If DecodeAnnotType(swAnnot.GetType) = "swNote" Then
        Set swAnnot = swAnnotations(j)
        Set swNote = swAnnot.GetSpecificAnnotation()
    
        Debug.Print "Name: " & swAnnot.GetName()
        Debug.Print "    Type: " & swAnnot.GetType
        Debug.Print "    Style: " & swNote.GetBalloonStyle
    
        Set swNote = swModelDocExt.EditBalloonProperties2(swBS_SplitCirc, swBF_5Chars, swBalloonTextCustom, "Upper", swBalloonTextCustom, "Lower", 0, True, 1, "X", 0.0355)
    
        Debug.Print "Name: " & swAnnot.GetName()
        Debug.Print "    Type: " & swAnnot.GetType
        Debug.Print "    Style: " & swNote.GetBalloonStyle
    End If
Next j

and here’s the immediate window output:

Name: DetailItem1872
    Type: 6
    Style: 1
Name: DetailItem1872
    Type: 6

The style is not shown because of it erroring out.

I tried the example code from https://help.solidworks.com/2022/english/api/sldworksapi/edit_balloon_example_vb.htm where it operates on a note (balloon) that is selected by the user and it works fine. It’s as if my EditBalloonProperties2 is corrupting the balloon that was selected using GetSpecificAnnotation(). My “Set swNote” statement is copied verbatim from the SW API Help example.

Thanks for your help.

GetSpecificAnnotation does not select the balloon. It only gets it. You have to select it before using EditBalloonProperties2.

Thank You, Josh. “BoolStatus = swAnnot.Select3(False, Nothing)” did the trick.