Property Let TypeControl(oObjet As Object, NameContainer As String, NameControl As String, _
NamePropriete As String, ValuePropriete As Variant)
' DONNE UNE VALEUR A UNE PROPRIETE A L'ENSEMBLE D'UN TYPE DE CONTROLE
Dim cTypeControl As Control
For Each cTypeControl In oObjet.Controls
If StrComp(TypeName(cTypeControl), NameControl, vbTextCompare) = 0 Then
If NameContainer = vbNullString Then
CallByName cTypeControl, NamePropriete, VbLet, ValuePropriete
Else
On Error Resume Next
If StrComp(cTypeControl.Container, NameContainer, vbTextCompare) = 0 Then
If Err = 0 Then CallByName cTypeControl, NamePropriete, VbLet, ValuePropriete
End If
End If
End If
Next
Set cTypeControl = Nothing
End Property
Remarque :
pour l'utiliser :
TypeControl(Me, vbNullString, "picturebox", "picture") = Nothing
TypeControl(Me, "", "checkbox", "value") = 0
TypeControl(Me, "Frame1", "Textbox", "Text") = vbNullString
On mettra vbnullstring ou "", pour que tous les contrôles de la feuille soient modifiés. On indiquera le "Conteneur", (Frame1), pour modifier que ceux contenus dans ce dernier.