Исправленная и немного оптимизированная версия функции Recurs:
Код:
Private Function Recurs(ByVal shp As Visio.Shape)
a1 = 0: a2 = 0
For i = 1 To shp.FromConnects.Count
If shp.FromConnects(i).FromPart = 9 Then
If a1 = 0 Then
a1 = i
Else
If a2 = 0 Then a2 = i
End If
End If
Next
If a1 <> 0 And a2 = 0 Then
GoShpOut shp, a1
End If
If a1 <> 0 And a2 <> 0 Then
s = shp.FromConnects(1).FromSheet.Text
If s = "Нет" Then
a3 = a1: a1 = a2: a2 = a3
End If
GoShpOut shp, a1
GoShpOut shp, a2
End If
End Function
Private Sub GoShpOut(ByVal shp As Visio.Shape, ByVal a As Integer)
Set shpOut = shp.FromConnects(a).FromSheet.Connects(2).ToSheet
shpName = Left(shpOut.Name, 7)
If shpName = "Process" And shpOut.Text = "" Then
n = n + 1
shpOut.Text = n
Recurs shpOut
End If
If shpName = "Decisio" And shpOut.Text = "" Then Recurs shpOut
End Sub