Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Difficultés avec CommandButton [Résolu]

Magic_Doctor

XLDnaute Barbatruc
Bonjour,

Dans ma feuille j'ai 4 CommandButtons nommés : "CommandButtonGraphique1", .... , "CommandButtonGraphique4".

Depuis un module standard, si j'écris :
Sheets("Tableaux").CommandButtonGraphique2.BackColor = &H56D61C
le "CommandButtonGraphique2" devient vert.

J'écris maintenant :
Dim num As Integer
num = 2

Sheets("Tableaux").Evaluate("CommandButtonGraphique" & num).Select
le "CommandButtonGraphique2" est sélectionné.

Mais si j'écris :
Sheets("Tableaux").Evaluate("CommandButtonGraphique" & num).BackColor = &H56D61C
Ça plante.

Merci d'avance de m'expliquer pourquoi.
 

Magic_Doctor

XLDnaute Barbatruc
J'ai fini par trouver.
Il fallait écrire :
Sheets("Tableaux").OLEObjects("CommandButtonGraphique" & num).Object.BackColor = &H56D61C

Mais ça marche aussi en écrivant :
Sheets("Tableaux").Evaluate("CommandButtonGraphique" & num).Object.BackColor = &H56D61C
 
Dernière édition:
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…