Partilhar via


Button.OLEType Property

Gets a value that represents the OLE object type.

Namespace:  Microsoft.Office.Tools.Excel.Controls
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property OLEType As Object
public Object OLEType { get; }

Property Value

Type: System.Object
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 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 Security

See Also

Reference

Button Class

Microsoft.Office.Tools.Excel.Controls Namespace