' dans le module ThisWorkBook
' c'est juste pour l'exemple, en vrai c'est un peu plus court
' pour etre seulement sur qq classeurs particuliers qui sont "marqués"
Public WithEvents xlapp As Application
Private Sub Workbook_Open()
Set xlapp = Application
End Sub
Private Sub xlapp_SheetActivate(ByVal Sh As Object)
UpdatePersoCb Sh.Parent
End Sub
Private Sub xlapp_WorkbookActivate(ByVal Wb As Workbook)
UpdatePersoCb Wb
End Sub
Sub UpdatePersoCb(ByVal Wb As Workbook)
Set cb = Application.CommandBars("Workbook tabs")
With cb
.Reset
With .Controls.Add(4, , , 1, True)
.OnAction = "testcb1"
For Each Sh In Wb.Sheets
.AddItem Sh.Name
Next
End With
End With
End Sub
Sub testcb1()
ActiveWorkbook.Sheets(CommandBars.ActionControl.Text).Activate
End Sub