Les propriétés
Cet exemple lit les propriétés du contrôle "Coller" :
La propriété GetImageMso permet de récupérer l'image d'un contrôle.
La procédure suivante affiche l'îcone du contrôle "Image" (onglet Insertion/Illustrations) dans un UserForm.
GetEnabledMso
GetImageMso
GetLabelMso
GetPressedMso
GetScreenTipMso
GetSuperTipMso
GetVisibleMso
permettent de récuperer des informations sur les contrôles prédéfinis du ruban, par VBA.GetImageMso
GetLabelMso
GetPressedMso
GetScreenTipMso
GetSuperTipMso
GetVisibleMso
Cet exemple lit les propriétés du contrôle "Coller" :
Code:
Sub Test()
Dim NomControle As String
NomControle = "Paste"
MsgBox ProprietesIdMso(NomControle), , "Propriétés du contrôle : " & NomControle
End Sub
Function ProprietesIdMso(strIdMso As String) As String
Dim Param As Variant
Param = "Label : " & Application.CommandBars.GetLabelMso(strIdMso) & vbCrLf
Param = Param & "Activé : " & Application.CommandBars.GetEnabledMso(strIdMso) & vbCrLf
'Attention, tous les contrôles n'ont pas de propriété "Pressed"
'Param = Param & Application.CommandBars.GetPressedMso(strIdMso) & vbCrLf
Param = Param & "Info bulle : " & Application.CommandBars.GetScreentipMso(strIdMso) & vbCrLf
Param = Param & "Info bulle complémentaire : " & Application.CommandBars.GetSupertipMso(strIdMso) & vbCrLf
Param = Param & "Visible : " & Application.CommandBars.GetVisibleMso(strIdMso) & vbCrLf
ProprietesIdMso = Param
End Function
La propriété GetImageMso permet de récupérer l'image d'un contrôle.
La procédure suivante affiche l'îcone du contrôle "Image" (onglet Insertion/Illustrations) dans un UserForm.
Code:
Private Sub CommandButton1_Click()
Dim NomControle As String
Dim Img As IPictureDisp
NomControle = "PictureInsertFromFile"
'GetImageMso(NomControle, largeur, hauteur)
Set Img = Application.CommandBars.GetImageMso(NomControle, 50, 50)
Set Image1.Picture = Img
End Sub
Dernière édition: