@Jesper_S
I modified the code a bit.
Do you mean something like that?
Class ThisRule
Dim moje As Integer = 1
Sub main
' MessageBox.Show("zacatek" & moje, "Title")
' Dim itemNr As String = InputBox(
' "Write the number of the position/baloon you are looking for",
' "Find baloon and zoom contains number Inputbox", "")
Dim itemNr As String = InputBox(
"CZ = Napište číslo pozice, které hledáte" & vbLf & "EN = Write the position number you are looking for", "Umístění Pozice na všech listech/Show location Baloon in All Sheets")
If itemNr = "" Then
MessageBox.Show("CZ = Příkaz ukončen" & vbLf & "EN = The command ended.", "Ukončení příkazu")
Return 'exit rule
End If
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
' Set a reference to the active sheet.
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet
Dim oBalloon As Balloon
Dim oBalloonValueSet As BalloonValueSet
Dim oSheet As Sheet
For Each oSheet In oDrawDoc.Sheets
oSheet.Activate
' MessageBox.Show("pp" & moje, "Title")
If moje = 2 Then
Exit For
Exit Sub
Else
' MessageBox.Show("funkce" & moje, "Title")
SearchBaolloon(oSheet, itemNr)
End If
If moje = 2 Then Exit For
Next
If moje = 2 Then Exit Sub
oActiveSheet.Activate 'return to original sheet
End Sub
Public Sub SearchBaolloon(sheet As Sheet, itemNr As String)
' For Each balloon As Balloon In Sheet.Balloons
' If (Balloon.BalloonValueSets.Item(1).ItemNumber = itemNr) Then
For Each balloon As Balloon In sheet.Balloons
For Each valueSet As BalloonValueSet In Balloon.BalloonValueSets
If (valueSet.ItemNumber = itemNr) Then
Dim p = Balloon.Position
Dim target = ThisApplication.TransientGeometry.CreatePoint(p.X, p.Y, 0)
Dim eye = ThisApplication.TransientGeometry.CreatePoint(p.X, p.Y, 100)
Dim diameter = Balloon.Style.BalloonDiameter
' looking at a full size baloon is no fun. Therefore we zoom out a bit
diameter = diameter * 7.5
Dim camera As Camera = ThisApplication.ActiveView.Camera
camera.Target = target
camera.Eye = eye
camera.SetExtents(diameter, diameter)
camera.Apply()
Dim result = MessageBox.Show(
"CZ = Chcete pokračovat k dalšímu výskytu pozice?" & vbLf & "EN = Do you want to continue to the next balloon occurrence?",
"Pokračuj na další pozici/Continue next Baloon", MessageBoxButtons.YesNo)
If (result = DialogResult.No) Then
moje = 2
MessageBox.Show("CZ = Příkaz ukončen" & vbLf & "EN = The command ended.", "Ukončení příkazu")
' MessageBox.Show("Ne" & moje, "Title")
Exit For
Exit Sub
Else
moje = 1
End If
End If
If moje = 2 Then Exit For
Next
If moje = 2 Then Exit For
' If moje = 2 Then Exit Sub'Function
' Return Nothing'Return False
Next
End Sub
End Class