Dela via


Worksheet.EnableSelection Property (2007 System)

Gets or sets a value indicating which cells can be selected on the sheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public Property EnableSelection As XlEnableSelection
'Usage
Dim instance As Worksheet 
Dim value As XlEnableSelection 

value = instance.EnableSelection

instance.EnableSelection = value
[BrowsableAttribute(false)]
public XlEnableSelection EnableSelection { get; set; }
[BrowsableAttribute(false)]
public:
property XlEnableSelection EnableSelection {
    XlEnableSelection get ();
    void set (XlEnableSelection value);
}
public function get EnableSelection () : XlEnableSelection 
public function set EnableSelection (value : XlEnableSelection)

Property Value

Type: XlEnableSelection
One of the XlEnableSelection values.

Remarks

This property takes effect only when the worksheet is protected: xlNoSelection prevents any selection on the sheet, xlUnlockedCells allows only those cells that are not locked to be selected, and xlNoRestrictions allows any cell to be selected.

Examples

The following code example uses the Protect method to protect the worksheet, and then uses the EnableSelection property to prevent any cell on the worksheet from being selected.

This example is for a document-level customization.

Private Sub ProtectAndDisableSelection()
    Me.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True, _
        UserInterfaceOnly:=True, AllowFormattingCells:=True, _
        AllowFormattingColumns:=False, AllowFormattingRows:=False, _
        AllowInsertingColumns:=False, AllowInsertingRows:=False, _
        AllowInsertingHyperlinks:=False, AllowDeletingColumns:=False, _
        AllowDeletingRows:=False, AllowSorting:=True, AllowFiltering:=True, _
        AllowUsingPivotTables:=True)
    Me.EnableSelection = Excel.XlEnableSelection.xlNoSelection
End Sub
private void ProtectAndDisableSelection()
{
    this.Protect(missing, true, true, true, true, true,
        false, false, false, false, false, false, false, true,
        true, true);
    this.EnableSelection = Excel.XlEnableSelection.xlNoSelection;
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace