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
Frédéric Sigonneau
Bonjour,
Une solution possible :
'====================== Sub CreateBO() 'Création de la barre d'outils "Forme Libre" With Application .ScreenUpdating = False .CommandBars.Add(Name:="Forme libre").Visible = True With .CommandBars("Forme libre") .Controls.Add Type:=msoControlButton, ID:!, Before:=1 .Controls.Add Type:=msoControlButton, ID:", Before:=2 .Controls.Add Type:=msoControlButton, ID: 6, Before:=1 .Controls.Add Type:=msoControlButton, ID: 0, Before:=1 With .Controls.Add(msoControlButton) .OnAction = "toto" .FaceId = 59 End With End With End With End Sub
Sub toto() MsgBox "coucou" End Sub '====================== FS -- Frédéric Sigonneau [MVP Excel - né un sans-culottide] Gestions de temps, VBA pour Excel : http://perso.wanadoo.fr/frederic.sigonneau Si votre question sur Excel est urgente, évitez ma bal !
Bonjour à toutes et tous.
J'ai une BO personnaliseé. Dans cette dernière, comment puis je ajouter un bouton qui actionnerait ma macro "toto".
Par avance merci
Sub CreateBO() 'Création de la barre d'outils "Forme Libre" With Application .ScreenUpdating = False .CommandBars.Add(Name:="Forme libre").Visible = True .CommandBars("Forme libre").Controls.Add Type:=msoControlButton, Id:!, Before:=1 .CommandBars("Forme libre").Controls.Add Type:=msoControlButton, Id:", Before:=2 .CommandBars("Forme libre").Controls.Add Type:=msoControlButton, Id: 6, Before:=1 .CommandBars("Forme libre").Controls.Add Type:=msoControlButton, Id: 0, Before:=1 End With ActiveSheet.Shapes.AddShape(msoShapeRectangle, 1, 1, 1, 1). _ Select With Selection.ShapeRange .Fill.Visible = msoFalse .Line.Weight = 0.5 .Line.ForeColor.SchemeColor = 48 .SetShapesDefaultProperties End With Selection.Delete End Sub
Bonjour,
Une solution possible :
'====================== Sub CreateBO()
'Création de la barre d'outils "Forme Libre"
With Application
.ScreenUpdating = False
.CommandBars.Add(Name:="Forme libre").Visible = True
With .CommandBars("Forme libre")
.Controls.Add Type:=msoControlButton, ID:!, Before:=1
.Controls.Add Type:=msoControlButton, ID:", Before:=2
.Controls.Add Type:=msoControlButton, ID: 6, Before:=1
.Controls.Add Type:=msoControlButton, ID: 0, Before:=1
With .Controls.Add(msoControlButton)
.OnAction = "toto"
.FaceId = 59
End With
End With
End With
End Sub
Sub toto()
MsgBox "coucou"
End Sub
'======================
FS
--
Frédéric Sigonneau [MVP Excel - né un sans-culottide]
Gestions de temps, VBA pour Excel :
http://perso.wanadoo.fr/frederic.sigonneau
Si votre question sur Excel est urgente, évitez ma bal !
Bonjour à toutes et tous.
J'ai une BO personnaliseé. Dans cette dernière, comment
puis je ajouter
un bouton qui actionnerait ma macro "toto".
Par avance merci
Sub CreateBO()
'Création de la barre d'outils "Forme Libre"
With Application
.ScreenUpdating = False
.CommandBars.Add(Name:="Forme libre").Visible = True
.CommandBars("Forme libre").Controls.Add
Type:=msoControlButton, Id:!, Before:=1
.CommandBars("Forme libre").Controls.Add
Type:=msoControlButton, Id:", Before:=2
.CommandBars("Forme libre").Controls.Add
Type:=msoControlButton, Id: 6, Before:=1
.CommandBars("Forme libre").Controls.Add
Type:=msoControlButton, Id: 0, Before:=1
End With
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 1, 1, 1,
1). _
Select
With Selection.ShapeRange
.Fill.Visible = msoFalse
.Line.Weight = 0.5
.Line.ForeColor.SchemeColor = 48
.SetShapesDefaultProperties
End With
Selection.Delete
End Sub
'====================== Sub CreateBO() 'Création de la barre d'outils "Forme Libre" With Application .ScreenUpdating = False .CommandBars.Add(Name:="Forme libre").Visible = True With .CommandBars("Forme libre") .Controls.Add Type:=msoControlButton, ID:!, Before:=1 .Controls.Add Type:=msoControlButton, ID:", Before:=2 .Controls.Add Type:=msoControlButton, ID: 6, Before:=1 .Controls.Add Type:=msoControlButton, ID: 0, Before:=1 With .Controls.Add(msoControlButton) .OnAction = "toto" .FaceId = 59 End With End With End With End Sub
Sub toto() MsgBox "coucou" End Sub '====================== FS -- Frédéric Sigonneau [MVP Excel - né un sans-culottide] Gestions de temps, VBA pour Excel : http://perso.wanadoo.fr/frederic.sigonneau Si votre question sur Excel est urgente, évitez ma bal !
Bonjour à toutes et tous.
J'ai une BO personnaliseé. Dans cette dernière, comment puis je ajouter un bouton qui actionnerait ma macro "toto".
Par avance merci
Sub CreateBO() 'Création de la barre d'outils "Forme Libre" With Application .ScreenUpdating = False .CommandBars.Add(Name:="Forme libre").Visible = True .CommandBars("Forme libre").Controls.Add Type:=msoControlButton, Id:!, Before:=1 .CommandBars("Forme libre").Controls.Add Type:=msoControlButton, Id:", Before:=2 .CommandBars("Forme libre").Controls.Add Type:=msoControlButton, Id: 6, Before:=1 .CommandBars("Forme libre").Controls.Add Type:=msoControlButton, Id: 0, Before:=1 End With ActiveSheet.Shapes.AddShape(msoShapeRectangle, 1, 1, 1, 1). _ Select With Selection.ShapeRange .Fill.Visible = msoFalse .Line.Weight = 0.5 .Line.ForeColor.SchemeColor = 48 .SetShapesDefaultProperties End With Selection.Delete End Sub