Boucle Sur Labels Pour changer le Font

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

salhi_haithem

XLDnaute Junior
Bonjour à tous,

J'ai Un UserForm qui contient des labels j'aimerai changer le font des labels de Times New Roman vers Tahoma ou Verdana ou arial avec un boucle

j'ai essayé ce Code mais il marche pas


Code:
Dim CTRL As Control
For Each CTRL In Me.Controls
    If TypeOf CTRL Is MSForms.Label Then 
    CTRL.Font = "Times New Roman"
    End If
Next CTRL

j'ai essayé ce Code et il marche pas aussi


Code:
For i = 0 To Me.Controls.Count - 1
If Left(Me.Controls.Item(i).Name, 5) = "Label" Then
Me.Controls.Item(i).Font = "Times New Roman" 
End If
Next i

merci d'avance pour votre aide
 
Re : Boucle Sur Labels Pour changer le Font

c'est bon j'ai trouvé la solution


Code:
Dim CTRL As Control

For Each CTRL In Me.Controls
If TypeOf CTRL Is MSForms.Label Then
        With CTRL
            .Font.Name = "Times New Roman"
            .Font.Size = 14
            .ForeColor = &HFF8080
            .BackColor = &H80000016
        End With
    End If
Next
 
Re : Boucle Sur Labels Pour changer le Font

j'aimerai savoir comment appliquer le même code avec ctrl listview

Code:
Dim CTRL As Control

For Each CTRL In Me.Controls
If TypeOf CTRL Is MSForms.listview Then
        With CTRL
            .Font.Name = "Times New Roman"
        End With
    End If
Next

ce code me veux pas fonctionner
 
Re : Boucle Sur Labels Pour changer le Font

De l'aide encore
comment faire un boucle sur les 9 listviews pour le code suivant

Code:
With ListView9
    
    If Me.CboPolice = "Times New Roman" Then
        .Font.Name = Me.CboPolice
        .Font.Size = 10
    ElseIf Me.CboPolice = "Monotype Corsiva" Then
        .Font.Name = Me.CboPolice
        .Font.Size = 12
     ElseIf Me.CboPolice = "Tahoma" Then
        .Font.Name = Me.CboPolice
        .Font.Size = 10
     ElseIf Me.CboPolice = "Verdana" Then
        .Font.Name = Me.CboPolice
        .Font.Size = 8
     ElseIf Me.CboPolice = "Arial Narrow" Then
        .Font.Name = Me.CboPolice
        .Font.Size = 11
    End If
    
End With

merci d'avance
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
8
Affichages
485
Réponses
7
Affichages
366
Réponses
3
Affichages
300
Réponses
10
Affichages
447
Réponses
21
Affichages
915
Retour