共用方式為


Button.OLEType 屬性

取得值,表示 OLE 物件型別。

命名空間:  Microsoft.Office.Tools.Excel.Controls
組件:  Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

語法

'宣告
Public ReadOnly Property OLEType As Object
    Get
public Object OLEType { get; }

屬性值

型別:System.Object
xlOLEControl

範例

下列程式碼範例會建立 Button 控制項,並將按鈕的文字指定為描述按鈕 OLE 物件型別的字串,即由 OLEType 屬性值所決定的型別。

這是示範文件層級自訂的範例。

Private Sub DisplayOLEType()
    Dim OleButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B2", "C3"), "OleButton1")

    Dim ControlType As String
    Select Case OleButton.OLEType
        Case Excel.XlOLEType.xlOLEControl
            ControlType = "OLE control"

        Case Excel.XlOLEType.xlOLEEmbed
            ControlType = "OLE embedded control"

        Case Excel.XlOLEType.xlOLELink
            ControlType = "OLE linked control"

        Case Else
            ControlType = "Not assigned an OLE type"
    End Select
    oleButton.Text = controlType
End Sub
private void DisplayOLEType()
{
    Microsoft.Office.Tools.Excel.Controls.Button oleButton =
            this.Controls.AddButton(this.Range["B2", "C3"],
            "oleButton1");

    string controlType;
    switch ((int)oleButton.OLEType)
    {
        case (int)Excel.XlOLEType.xlOLEControl:
            controlType = "OLE control";
            break;

        case (int)Excel.XlOLEType.xlOLEEmbed:
            controlType = "OLE embedded control";
            break;

        case (int)Excel.XlOLEType.xlOLELink:
            controlType = "OLE linked control";
            break;

        default:
            controlType = "Not assigned an OLE type";
            break;
    }
    oleButton.Text = controlType;
}

.NET Framework 安全性

請參閱

參考

Button 類別

Microsoft.Office.Tools.Excel.Controls 命名空間