Share via


ToSheet Property [Visio 2003 SDK Documentation]

Returns the shape to which one or more connections are made.

objRet = object**.ToSheet**

objRet     The Shape object to which the connection is made.

object     Required. An expression that returns a Connect object or Connects collection.

Version added

2.0

Remarks

The ToSheet property for a Connect object always returns the shape to which the connection is made.

The Connects collection represents several connections. If every connection represented by the collection is made to the same shape, the ToSheet property returns that shape. Otherwise, it returns Nothing and does not raise an exception.

Example

This Microsoft Visual Basic for Applications (VBA) macro shows how to use the ToSheet property to find the shape a Connect object originates from in a Microsoft Office Visio drawing. The example displays the connection information in the Immediate window.

This example assumes there is an active document that contains at least two connected shapes. For best results, connect two shapes from the Organization Chart stencil.

Public Sub ToSheet_Example()
 
    Dim vsoShapes As Visio.Shapes 
    Dim vsoShape As Visio.Shape 
    Dim vsoConnectTo As Visio.Shape 
    Dim vsoConnects As Visio.Connects 
    Dim vsoConnect As Visio.Connect 
    Dim intCurrentShapeIndex As Integer
    Dim intCounter As Integer
    Set vsoShapes = ActivePage.Shapes
 
    'For each shape on the page, get its connections.
    For intCurrentShapeIndex = 1 To vsoShapes.Count 

        Set vsoShape = vsoShapes(intCurrentShapeIndex) 
        Set vsoConnects = vsoShape.Connects 

        'For each connection, get the shape it connects to.
        For intCounter = 1 To vsoConnects.Count 

            Set vsoConnect = vsoConnects(intCounter) 
            Set vsoConnectTo = vsoConnect.ToSheet 

            'Print the name of the shape the 
            'Connect object connects to. 
            Debug.Print vsoConnectTo.Name 

        Next intCounter 

    Next intCurrentShapeIndex
 
End Sub

Applies to | Connect object | Connects collection

See Also | FromSheet property | GlueTo method