1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
Sub Bouton_Excel_Convertopdf_Interactive()
Dim labarre As CommandBar
Dim LeBouton As CommandBarButton
Dim NomDeLaBarre, NomMacro, NomClasseur, CheminEtNomImage, ActionDubouton As String
ActionDubouton = "Print in PDF using CutePDF (Interactive Mode)"
NomDeLaBarre = "MyCutePDF"
NomMacro = "Converttopdf_Interactive"
NomClasseur = "GSAPI_VBA.xls" 'GhostScript Api's
CheminEtNomImage = ActiveWorkbook.Path & "\Icon_Pdf_1.bmp"
'Insère l'image du bouton dans la feuille Excel
ActiveSheet.Pictures.Insert(CheminEtNomImage).Select
'Copie l'image en vue de son application au bouton
Selection.Copy
Set labarre = CommandBars(NomDeLaBarre)
'Ajoute le bouton à la barre d'outils personnalisée
Set LeBouton = labarre.Controls.Add(Type:=msoControlButton)
LeBouton.FaceId = 0
LeBouton.Caption = ActionDubouton 'info-bulle du bouton
LeBouton.OnAction = "'" & NomClasseur & "'!" & NomMacro
'Collage de l'image sur le bouton
LeBouton.PasteFace
'Suppression de l'image dans la feuille de calculs
Selection.Delete
Set labarre = Nothing
Set LeBouton = Nothing
End Sub |