Share via


Window.SelectedCell Property

Visio Automation Reference

Returns the selected cell in the ShapeSheet window. Read-only.

Version Information
 Version Added:  Visio 2003

Syntax

expression.SelectedCell

expression   A variable that represents a Window object.

Return Value
Cell

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.

Visual Basic for Applications
  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

See Also