je cherche un petit truc simple
à partir de VBA, comment à l'ouverture d'un fichier excel créer une barre
d'outils
Cette barre d'outils doit disparaitre à la fermeture du fichier excel
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
ChrisV
Bonjour calendrier,
Par exemple...
Dans la feuille de code de ThisWorkbook:
Private Sub Workbook_BeforeClose(Cancel As Boolean) DeleteBO End Sub
Private Sub Workbook_Open() CreateBO End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window) On Error Resume Next Application.CommandBars(nomBO).Visible = True End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window) On Error Resume Next Application.CommandBars(nomBO).Visible = False End Sub
dans un module:
Public Const nomBO = "Ma barre d'outils personnalisée"
Sub CreateBO() Dim bo As CommandBar On Error Resume Next DeleteBO Set bo = Application.CommandBars.Add(nomBO) With bo.Controls.Add(msoControlButton) .Caption = "Titre 1" .FaceId = 487 .OnAction = "Macro1" End With With bo.Controls.Add(msoControlButton) .Caption = "Titre 2" .FaceId = 210 .OnAction = "Macro2" End With With bo.Controls.Add(msoControlButton) .Caption = "Titre 3" .FaceId = 211 .OnAction = "Macro3" End With With bo.Controls.Add(msoControlButton) .Caption = "Titre 4" .FaceId = 266 .OnAction = "Macro4" .BeginGroup = True End With With bo.Controls.Add(msoControlButton) .Caption = "Titre5" .FaceId = 2151 .OnAction = "Macro5" End With bo.Visible = True End Sub
Sub DeleteBO() On Error Resume Next Application.CommandBars(nomBO).Delete End Sub
ChrisV
"calendrier" a écrit dans le message de news:
Bonjour,
bonne année à tous ceux qui sont là et pas là
je cherche un petit truc simple à partir de VBA, comment à l'ouverture d'un fichier excel créer une barre d'outils Cette barre d'outils doit disparaitre à la fermeture du fichier excel
mon fichier s'apelle "COMPTA"
merci à l'avance pour votre aide
jean marie
Bonjour calendrier,
Par exemple...
Dans la feuille de code de ThisWorkbook:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
DeleteBO
End Sub
Private Sub Workbook_Open()
CreateBO
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
On Error Resume Next
Application.CommandBars(nomBO).Visible = True
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
On Error Resume Next
Application.CommandBars(nomBO).Visible = False
End Sub
dans un module:
Public Const nomBO = "Ma barre d'outils personnalisée"
Sub CreateBO()
Dim bo As CommandBar
On Error Resume Next
DeleteBO
Set bo = Application.CommandBars.Add(nomBO)
With bo.Controls.Add(msoControlButton)
.Caption = "Titre 1"
.FaceId = 487
.OnAction = "Macro1"
End With
With bo.Controls.Add(msoControlButton)
.Caption = "Titre 2"
.FaceId = 210
.OnAction = "Macro2"
End With
With bo.Controls.Add(msoControlButton)
.Caption = "Titre 3"
.FaceId = 211
.OnAction = "Macro3"
End With
With bo.Controls.Add(msoControlButton)
.Caption = "Titre 4"
.FaceId = 266
.OnAction = "Macro4"
.BeginGroup = True
End With
With bo.Controls.Add(msoControlButton)
.Caption = "Titre5"
.FaceId = 2151
.OnAction = "Macro5"
End With
bo.Visible = True
End Sub
Sub DeleteBO()
On Error Resume Next
Application.CommandBars(nomBO).Delete
End Sub
ChrisV
"calendrier" <calendrier@discussions.microsoft.com> a écrit dans le message
de news: ADAA85D6-2864-44CE-80B2-B208B1CB3D6C@microsoft.com...
Bonjour,
bonne année à tous ceux qui sont là et pas là
je cherche un petit truc simple
à partir de VBA, comment à l'ouverture d'un fichier excel créer une barre
d'outils
Cette barre d'outils doit disparaitre à la fermeture du fichier excel
Private Sub Workbook_BeforeClose(Cancel As Boolean) DeleteBO End Sub
Private Sub Workbook_Open() CreateBO End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window) On Error Resume Next Application.CommandBars(nomBO).Visible = True End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window) On Error Resume Next Application.CommandBars(nomBO).Visible = False End Sub
dans un module:
Public Const nomBO = "Ma barre d'outils personnalisée"
Sub CreateBO() Dim bo As CommandBar On Error Resume Next DeleteBO Set bo = Application.CommandBars.Add(nomBO) With bo.Controls.Add(msoControlButton) .Caption = "Titre 1" .FaceId = 487 .OnAction = "Macro1" End With With bo.Controls.Add(msoControlButton) .Caption = "Titre 2" .FaceId = 210 .OnAction = "Macro2" End With With bo.Controls.Add(msoControlButton) .Caption = "Titre 3" .FaceId = 211 .OnAction = "Macro3" End With With bo.Controls.Add(msoControlButton) .Caption = "Titre 4" .FaceId = 266 .OnAction = "Macro4" .BeginGroup = True End With With bo.Controls.Add(msoControlButton) .Caption = "Titre5" .FaceId = 2151 .OnAction = "Macro5" End With bo.Visible = True End Sub
Sub DeleteBO() On Error Resume Next Application.CommandBars(nomBO).Delete End Sub
ChrisV
"calendrier" a écrit dans le message de news:
Bonjour,
bonne année à tous ceux qui sont là et pas là
je cherche un petit truc simple à partir de VBA, comment à l'ouverture d'un fichier excel créer une barre d'outils Cette barre d'outils doit disparaitre à la fermeture du fichier excel