AnsweredAssumed Answered

Delete all Balloons - DeleteSelection2 => ignore rest of notes? 

Question asked by Niels Raahauge on Jun 18, 2020
Latest reply on Jun 19, 2020 by Niels Raahauge

'Want to delete all ballons.

'Macro scan view for balloon - if found select and delete selected.  (DeleteSelection2)

'Problem: When I use DeleteSelection2, => Note Is then Nothing and code goes to next view.(there is more notes)

'If DeleteSelection2 is comment out - then it will find all the balloons in the view?

 

'Why is notes goto nothing when I use DeleteSelection2 ? There is more notes in the view....

'(Maby a solution is to make a collection of selection - and the delete - but I would like to know why it jump to next view )

 

'Delete all baloon in all views

Dim swApp As Object
Dim Drw As Object
Dim View As Object
Dim Note As Object
Dim Bool As Boolean
Dim longstatus As Long


Sub main()

Set swApp = Application.SldWorks
Set Drw = swApp.ActiveDoc


If Not Drw Is Nothing Then

If Drw.GetType = 3 Then 'Activedoc = Drawing?

Set View = Drw.GetFirstView '= drawing sheet
Set View = View.GetNextView '= first real view

While Not View Is Nothing 'loop through views
Debug.Print "Look in view " & View.GetName2

Set Note = View.GetFirstNote

While Not Note Is Nothing 'loop through notes

If Note.IsBomBalloon Then

Dim nnavn As String
Dim booleanstatus As Boolean

 

Debug.Print " item " & Note.GetName
nnavn = Note.GetName & "@" & View.GetName2 'ID for balloon
Debug.Print " ID " & nnavn

 

boolstatus = Drw.Extension.SelectByID2(nnavn & "@" & View.GetName2, "NOTE", 0, 0, 0, False, 0, Nothing, 0)
Stop ' If I take out the next line - it will find all balloons ...
longstatus = Drw.Extension.DeleteSelection2(SwConst.swDelete_Absorbed) 'SwConst.swDelete_Children or 0

End If

Set Note = Note.GetNext

Wend

Set View = View.GetNextView

Wend

End If

End If

End Sub

Outcomes