Boucle Sur Labels Pour changer le Font

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
 

salhi_haithem

XLDnaute Junior
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
 

salhi_haithem

XLDnaute Junior
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
 

salhi_haithem

XLDnaute Junior
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
 

Discussions similaires

Réponses
3
Affichages
327

Statistiques des forums

Discussions
312 328
Messages
2 087 317
Membres
103 515
dernier inscrit
Cherbil12345