• Connected shapes (Excel W2K03)

    Author
    Topic
    #425150

    Greetings loungers

    I am attempting to trace a series of connected shapes.
    Using the connector property and connectorFormat enables this.
    The problem is that it seems the connector shapes are evaluated in their creation order.

    I would prefer to establish recursively
    if a shape has an attached connector (and the number of connectors)
    … then if so establish the end point of that connector and grab the text

    loop

    IT is almost as if there is a need for an “IsConnected” function.

    Thanks

    Geof

    Sub ConnectionEnd()
    For Each oShp In ActiveSheet.Shapes
    If oShp.Connector Then
    With oShp.ConnectorFormat
    If .EndConnected Then
    Set endshape = .EndConnectedShape
    endshape.Select
    MsgBox (Selection.Name)

    End If
    End With

    End If
    Next
    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #978671

      The following is very rough and can no doubt be improved significantly, but it might help you on your way:

      Sub TraceConnectors()
      FindLastConnectorText ActiveSheet.Shapes(1)
      End Sub

      Sub FindLastConnectorText(shp As Shape)
      Dim shp1 As Shape, shp2 As Shape
      Set shp1 = shp
      Do
      Set shp2 = GetConnector(shp1)
      If Not shp2 Is Nothing Then
      Set shp1 = GetConnected(shp2)
      Else
      MsgBox shp1.TextFrame.Characters.Text
      Set shp1 = Nothing
      End If
      Loop Until shp1 Is Nothing
      End Sub

      Function GetConnector(shp As Shape) As Shape
      Dim con As Shape
      For Each con In ActiveSheet.Shapes
      If con.Connector Then
      If con.ConnectorFormat.BeginConnectedShape.Name = shp.Name Then
      Set GetConnector = con
      Exit For
      End If
      End If
      Next con
      End Function

      Function GetConnected(con As Shape) As Shape
      ‘ con is assumed to be a connector!
      If con.ConnectorFormat.EndConnected Then
      Set GetConnected = con.ConnectorFormat.EndConnectedShape
      End If
      End Function

      • #978686

        Hello Hans
        Thanks for this.
        It will take a bit to get my head around it.

        I appreciate the start.

        Geof

    Viewing 0 reply threads
    Reply To: Connected shapes (Excel W2K03)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: