Partager via


Button.OLEType Property

Definition

Gets a value that represents the OLE object type.

public:
 property System::Object ^ OLEType { System::Object ^ get(); };
public object OLEType { get; }
member this.OLEType : obj
Public ReadOnly Property OLEType As Object

Property Value

An xlOLEControl.

Examples

The following code example creates a Button control and assigns the button text to a string that describes the OLE object type of the button, as determined by the OLEType property value.

This example is for a document-level customization.

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;
}
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

Applies to