Need Help with EditBalloonProperties2

Programming and macros
User avatar
loeb
Posts: 68
Joined: Sun Jan 16, 2022 5:55 pm
Answers: 1
x 39
x 10

Need Help with EditBalloonProperties2

Unread post by loeb »

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:

Code: Select all

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:

Code: Select all

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/englis ... ple_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.
by josh » Mon Sep 09, 2024 11:28 am
GetSpecificAnnotation does not select the balloon. It only gets it. You have to select it before using EditBalloonProperties2.
Go to full post
User avatar
josh
Posts: 295
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 16
x 22
x 508

Re: Need Help with EditBalloonProperties2

Unread post by josh »

GetSpecificAnnotation does not select the balloon. It only gets it. You have to select it before using EditBalloonProperties2.
User avatar
loeb
Posts: 68
Joined: Sun Jan 16, 2022 5:55 pm
Answers: 1
x 39
x 10

Re: Need Help with EditBalloonProperties2

Unread post by loeb »

Thank You, Josh. "BoolStatus = swAnnot.Select3(False, Nothing)" did the trick.
Post Reply