次の方法で共有


WorksheetBase.EnableSelection プロパティ

シート上で選択可能なセルを示す値を取得または設定します。

名前空間:  Microsoft.Office.Tools.Excel
アセンブリ:  Microsoft.Office.Tools.Excel.v4.0.Utilities (Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 内)

構文

'宣言
Public Property EnableSelection As XlEnableSelection
    Get
    Set
public XlEnableSelection EnableSelection { get; set; }

プロパティ値

型: Microsoft.Office.Interop.Excel.XlEnableSelection
いずれかの XlEnableSelection 値。

解説

このプロパティは、ワークシートが保護されている場合のみ有効です。xlNoSelection では、ワークシート上のすべてのオブジェクトを選択できないようにします。xlUnlockedCells では、選択できないようロックされているオブジェクト以外を選択できます。xlNoRestrictions では、すべてのセルが選択できます。

次のコード例では、Protect メソッドを使用してワークシートを保護し、EnableSelection プロパティを使用してワークシート上のすべてのセルを選択できないようにします。

この例は、ドキュメント レベルのカスタマイズ用に作成されています。

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 セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

WorksheetBase クラス

Microsoft.Office.Tools.Excel 名前空間