Microsoft 365 UF affiche les captions enregistrées dans les fenêtres propriétés des CommandButton

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour à toutes et à tous,
Je vous souhaite une belle journée :)

J'ai récupéré sur le Forum un classeur qui contient un UserForm, encore merci à son auteur.

Je voudrais qu'à l'affichage, l'UF affiche les captions enregistrées dans les fenêtres propriétés des CommandButton.
1620891396042.png

Evidemment, je n'y arrive pas :mad:
Pourriez-vous m'aider ?
Je joins le fichier test,
Avec mes remerciements,
Amicalement,
lionel,
 

Pièces jointes

  • MsgBoxPerso_Test.xlsm
    128.7 KB · Affichages: 15
Solution
Euréka fé du matin, j'ai trouvé :)
VB:
Private Sub UserForm_Initialize()
  Dim Ind As Integer, Last As Integer
  ' Pour chaque libellé de bouton du tableau
  For Ind = 0 To UBound(TabBtn)
    ' Afficher son libellé
    Me("CommandButton" & 1 + Ind).Caption = TabBtn(Ind)
  Next Ind
  ' Masquer le reste des boutons
  For Last = 1 + Ind To 5
    Me("CommandButton" & Last).Visible = False
  Next Last
  Me.CommandButton1.Caption = "Tu veux ?"
  Me.CommandButton2.Caption = "Ou tu veux pas ?"
  Me.CommandButton3.Caption = "Si c'est OUI"
  Me.CommandButton4.Caption = "Tant mieux"
  Me.CommandButton5.Caption = "Sinon tant pis"
End Sub
Mais n'affiche pas si les Captions sont uniquement enregistrées dans les propriétés !
Je...

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Euréka fé du matin, j'ai trouvé :)
VB:
Private Sub UserForm_Initialize()
  Dim Ind As Integer, Last As Integer
  ' Pour chaque libellé de bouton du tableau
  For Ind = 0 To UBound(TabBtn)
    ' Afficher son libellé
    Me("CommandButton" & 1 + Ind).Caption = TabBtn(Ind)
  Next Ind
  ' Masquer le reste des boutons
  For Last = 1 + Ind To 5
    Me("CommandButton" & Last).Visible = False
  Next Last
  Me.CommandButton1.Caption = "Tu veux ?"
  Me.CommandButton2.Caption = "Ou tu veux pas ?"
  Me.CommandButton3.Caption = "Si c'est OUI"
  Me.CommandButton4.Caption = "Tant mieux"
  Me.CommandButton5.Caption = "Sinon tant pis"
End Sub
Mais n'affiche pas si les Captions sont uniquement enregistrées dans les propriétés !
Je n'ai pas trouvé pourquoi ?

Voilà le fichier :)
Bonne journée :)
lionel,
 

Pièces jointes

  • MsgBoxPerso_Test.xlsm
    24 KB · Affichages: 6
Dernière édition:

ChTi160

XLDnaute Barbatruc
Re
je viens de regarder
j'ai modifié les Valeurs du TabBtn
et cela m'affiche bien les Libellés
pas sur d'avoir Compris Lol
Bonne journée
jean marie
 

Pièces jointes

  • MsgBoxPerso_Test Chti160.xlsm
    23.3 KB · Affichages: 4

ChTi160

XLDnaute Barbatruc
Si tu regardes je n'ai rien ajouté
c'était déjà dans le Fichier Module 1 y'avait :

Option Explicit

Public TabBtn() As String

Sub test()
'msgbox(Prompt,Button,Title)
[h4].Select
MsgBoxPerso "", "Bouton1,LibBouton2,TestBouton3,TestBouton4,TestBouton5", "CLIC SUR LA REPONSE"
[a1].Select
End Sub
' Procédure générale de mise en place des éléments
Sub MsgBoxPerso(Prompt As String, Button As String, Title As String)
TabBtn = Split(Button, ",")
UsFMsg.Caption = Title
UsFMsg.Label1.Caption = Prompt
UsFMsg.Show (1)
End Sub
j'ai juste mis le Code dans le Userform Initialize et adapté Lol
suppression de test et MsgBoxPerso
pas de triche en somme Lol
Jean marie
 

TooFatBoy

XLDnaute Barbatruc
Bonjour,

Euréka fé du matin, j'ai trouvé :)
VB:
Private Sub UserForm_Initialize()
  Dim Ind As Integer, Last As Integer
  ' Pour chaque libellé de bouton du tableau
  For Ind = 0 To UBound(TabBtn)
    ' Afficher son libellé
    Me("CommandButton" & 1 + Ind).Caption = TabBtn(Ind)
  Next Ind
  ' Masquer le reste des boutons
  For Last = 1 + Ind To 5
    Me("CommandButton" & Last).Visible = False
  Next Last
  Me.CommandButton1.Caption = "Tu veux ?"
  Me.CommandButton2.Caption = "Ou tu veux pas ?"
  Me.CommandButton3.Caption = "Si c'est OUI"
  Me.CommandButton4.Caption = "Tant mieux"
  Me.CommandButton5.Caption = "Sinon tant pis"
End Sub
Mais n'affiche pas si les Captions sont uniquement enregistrées dans les propriétés !
Je n'ai pas trouvé pourquoi ?
C'est étrange ton affaire de texte qui ne s'affiche pas dans tes boutons !...🤔

Il y a quoi dans ton tableau TabBtn() ?
Ce tableau est initialisé où ?

Et ça sert à quoi d'initialiser les textes des boutons vu que tu les changes après ?
 

Discussions similaires

Réponses
16
Affichages
2 K
Réponses
8
Affichages
760

Statistiques des forums

Discussions
312 178
Messages
2 085 984
Membres
103 079
dernier inscrit
sle