'Fonction pour savoir si une listbox a la scrollbar d'affichée ou pas
'patricktoulon
'Rheeem
'jurassic pork
'dudu2
Option Explicit
#If VBA7 Then
    Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    Private Declare PtrSafe Function AccessibleObjectFromPoint Lib "oleacc" (ByVal Rw As Currency, ppacc As IAccessible, pvarChild As Variant) As Long
    Private Declare PtrSafe Function WindowFromAccessibleObject Lib "oleacc" (ByVal pacc As IAccessible, phwnd As LongPtr) As Long
    Private Declare PtrSafe Function GetWindowRect Lib "user32" (ByVal hwnd As LongPtr, lpRect As rect) As Long
#Else
    Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    Private Declare Function AccessibleObjectFromPoint Lib "oleacc" (ByVal Rw As Currency, ppacc As IAccessible, pvarChild As Variant) As Long
    Private Declare Function WindowFromAccessibleObject Lib "oleacc" (ByVal pacc As IAccessible, phwnd As Long) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As rect) As Long
#End If
Private Const SM_CXVSCROLL = 2
Private Type rect: left As Long: top As Long: right As Long: bottom As Long: End Type
Private Type CPoint: X As Long: Y As Long: End Type
Private Type CRw: Dt As Currency: End Type
Function HasScrollbarVX(ByVal Lb As MSForms.ListBox) As Boolean
    Dim cc As IAccessible, b As CPoint, pz As CRw, v As Variant, retrait&, IAcObj As IAccessible, rc As rect, q$
    retrait = GetSystemMetrics(SM_CXVSCROLL) / 2
    If Lb.ListCount = 0 Then Exit Function
    If TypeOf Lb.Parent Is Worksheet Then
        With ActiveWindow.ActivePane
            b.X = .PointsToScreenPixelsX(Lb.left + Lb.Width - retrait)
            b.Y = .PointsToScreenPixelsY(Lb.top + retrait)
        End With
    Else
        #If VBA7 Then
            Dim Handl As LongPtr
        #Else
            Dim Handl As Long
        #End If
        Set IAcObj = Lb
        WindowFromAccessibleObject IAcObj, Handl
        GetWindowRect Handl, rc
        With Lb.Parent.TextBox1
            q = "Left : " & rc.left & vbCrLf
            q = q & "Top : " & rc.top & vbCrLf
            q = q & "Right : " & rc.right & vbCrLf
            q = q & "Bottom : " & rc.bottom
            .Value = q
        End With
        b.X = rc.right - retrait
        b.Y = rc.top + retrait
    End If
    LSet pz = b
    AccessibleObjectFromPoint pz.Dt, cc, v
    HasScrollbarVX = v = 0
End Function