introduction de boutons

  • Initiateur de la discussion Xavier
  • Date de début
X

Xavier

Guest
Bonjour,

J'aimerais introduire deux boutons sur une feuille que j'ai crée ainsi qu'un combobox sur la meme feuille .... comme je suis ignorant ou fainéant, j'utilise pour ce faire l'enregistreur macro et ensuite j'introduis la copie dans mon fichier de base. Malheureusement pour moi, ca ne fonctionne pas ... il me parle de Method "Select" of Objet shape failed ... ce qui est assez génant

Pouvez vous m'aidez svp? merci bcp

XA

Voici le code que j'utilise
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=623.25, Top:=12.75, Width:=72, Height:= _
24).Select
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=624, Top:=51, Width:=72, Height:=24). _
Select
ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False, _
DisplayAsIcon:=False, Left:=18, Top:=13.5, Width:=72, Height:=18). _
Select

' ca foire ici
ActiveSheet.Shapes("CommandButton1").Select
ActiveSheet.Shapes("CommandButton2").Select
Selection.ShapeRange.ScaleWidth 1.16, msoFalse, msoScaleFromBottomRight
Range("M3").Select
ActiveSheet.Shapes("Global_TOP").Select
Selection.ShapeRange.ScaleWidth 1.14, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.IncrementLeft 24.75
Selection.ShapeRange.IncrementTop 0.75
ActiveSheet.Shapes("Global_Down").Select
Selection.ShapeRange.IncrementLeft 23.25
ActiveSheet.Shapes("ComboBox1").Select
Selection.ShapeRange.IncrementLeft -9.75
Selection.ShapeRange.IncrementTop 6.75
 
M

michel

Guest
bonsoir Xavier

mais j'espere que cette macro pourra t'aider


Sub CreationCommandButton()
Dim oOLE As OLEObject
Dim X As Byte

Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
Link:=False, DisplayAsIcon:=False, Left:=340, Top:=30, Width:=100, Height:=30)
'Left position bouton par rapport au bord gauche de la feuille
'Top position bouton par rapport au haut de la feuille
'Width largeur bouton
'Height hauteur bouton

X = ActiveSheet.OLEObjects.Count 'compter le nombre de boutons existants dans la feuille

'option nommer l'objet
oOLE.Name = "CommandButton" & X
'texte sur le bouton
ActiveSheet.OLEObjects(X).Object.Caption = "Le Forum XLD " & X

End Sub


bonne soiree
MichelXld
 

Discussions similaires

Réponses
16
Affichages
1 K

Statistiques des forums

Discussions
312 504
Messages
2 089 073
Membres
104 018
dernier inscrit
Mzghal