Partager via


Button.OLEType, propriété

Obtient une valeur qui représente le type d'objet OLE.

Espace de noms :  Microsoft.Office.Tools.Excel.Controls
Assembly :  Microsoft.Office.Tools.Excel.v4.0.Utilities (dans Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntaxe

'Déclaration
Public ReadOnly Property OLEType As Object
public Object OLEType { get; }

Valeur de propriété

Type : System.Object
Élément xlOLEControl.

Exemples

L'exemple de code suivant crée un contrôle Button et assigne au texte du bouton une chaîne qui décrit le type d'objet OLE du bouton, comme spécifié par la valeur de la propriété OLEType.

Cet exemple illustre une personnalisation au niveau du document.

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

Sécurité .NET Framework

Voir aussi

Référence

Button Classe

Microsoft.Office.Tools.Excel.Controls, espace de noms