Share via


SelectedCell Property [Visio 2003 SDK Documentation]

Returns the selected cell in the ShapeSheet window.

objRet = object.SelectedCell

objRet     The selected Cell object.

object     Required. An expression that returns a Window object.

Version added

2003

Remarks

The SelectedCell property applies only to ShapeSheet windows. If you try to access the SelectedCell property for any other type of window, Visio returns the error message "Invalid window type for this action."

If a ShapeSheet row is selected (instead of a cell), SelectedCell returns Nothing. See the following example.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the SelectedCell property to print the name, section, row, column, and formula of the selected ShapeSheet cell in the Immediate window.

Public Sub SelectedCell_Example()

    Dim vsoCell As Visio.Cell

    Set vsoCell = Application.ActiveWindow.SelectedCell

    'If vsoCell is Nothing, a row is probably selected.
    If (Not vsoCell Is Nothing) Then
         Debug.Print "Cell Name:  " & vsoCell.Name
         Debug.Print "Section: " & vsoCell.Section
         Debug.Print "Row: " & vsoCell.Row
         Debug.Print "Column: " & vsoCell.Column
         Debug.Print "Formula: " & vsoCell.Formula
    Else
         Debug.Print "vsoCell is Nothing--a row is probably selected."

    End If

End Sub

Applies to | Window object

See Also | Cell object