Créer un bouton et le nommer

Hello

Franchement je suis nul je n'arrive pas à créer un bouton et lui donner un nom en même temps ....

Ci-dessous le code et ce qui est "marrant" c'est que la macro ne plante pas à la ligne selection.name mais le name et bé il est nulle part....

Une idée quelqu'un ?

ActiveSheet.Buttons.Add(298.5, 185.25, 175.5, 48.75).Select
Selection.Name = "PPM"
'Selection.OnAction = "Macro4"
Selection.Caption = "Cliquez Ici pour lancer les annulations"
        With Selection.Characters(Start:=1, Length:=39).Font
        .Name = "Cambria"
        .FontStyle = "Normal"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        End With

Bonjour

Filou78 a écrit :

mais le name et bé il est nulle part....

bouton

C'est ce que tu cherches ?

Bonjour,

Voir procédure ci-dessous à adapter.

Cdlt.

Option Explicit

Public Sub DEMO()
Dim ws As Worksheet
Dim btn As Button

    Application.ScreenUpdating = False

    Set ws = ActiveSheet
    ws.Buttons.Delete

    Set btn = ws.Buttons.Add(298.5, 185.25, 175.5, 48.75)

    With btn
        .OnAction = "Macro4"
        .Caption = "Cliquez Ici pour lancer les annulations"
        .Name = "PPM"
        With .Characters(Start:=1, Length:=39).Font
            .Name = "Cambria"
            .FontStyle = "Normal"
            .Size = 11
        End With
    End With

    Set btn = Nothing: Set ws = Nothing

End Sub

Public Sub Macro4()

    MsgBox "Bonjour " & Application.UserName & " !"

End Sub

Merci c'est parfait !!!

Rechercher des sujets similaires à "creer bouton nommer"