Rapport de message :*
 

Re: Excel 2010 - Onglet 'Compléments' devenu invisible

Titre du sujet : Re: Excel 2010 - Onglet 'Compléments' devenu invisible
par yaka le 22/04/2011 17:32:50

Hello et merci.

En désespoire de cause je passerai par le menu contextuel...

voici mon code :

dans Thisworkbook :

Private Sub Workbook_AddinInstall()
    creerBoutonMenu
End Sub


Private Sub Workbook_Open()
    creerBoutonMenu
End Sub




Dans un module :

Sub creerBoutonMenu()

    Dim nomBTmenu As String: nomBTmenu = VBA.Left(ThisWorkbook.Name, InStr(ThisWorkbook.Name, ".") - 1)
   
   
    On Error Resume Next
    Dim test As String
    test = Application.CommandBars(1).Controls(nomBTmenu).Caption
    If Err.Number > 0 Then 'si le bouton n'existe pas
        Dim BTmenu As CommandBarButton
        Set BTmenu = Application.CommandBars(1).Controls.Add(Type:=1, Temporary:=True)
        With BTmenu
            .BeginGroup = True
                    .Caption = nomBTmenu
            .FaceId = 1106
            .OnAction = "AfficherRH"
            .TooltipText = "Reporting des Heures"
            .Style = msoButtonIconAndCaption
        End With
   
    End If

End Sub