[Excel 2007] Lire les propriétés des contrôles prédéfinis idMso

MichelXld

XLDnaute Barbatruc
Les propriétés

GetEnabledMso
GetImageMso
GetLabelMso
GetPressedMso
GetScreenTipMso
GetSuperTipMso
GetVisibleMso
permettent de récuperer des informations sur les contrôles prédéfinis du ruban, par VBA.

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:

Statistiques des forums

Discussions
311 725
Messages
2 081 940
Membres
101 845
dernier inscrit
annesof