Function IsReady4UI(TitreFen) As Integer
Dim c As New CUIAutomation, oExcel As IUIAutomationElement, oUSF As IUIAutomationElement
Set oExcel = c.ElementFromHandle(ByVal Application.ActiveWindow.hwnd)
Set oUSF = GetUiElem(c, oExcel, "Name", TitreFen, TreeScope_Children)
Debug.Print oUSF.CurrentName
IsReady4UI = oUSF.GetCurrentPropertyValue(UIAutomationClient.UIA_WindowWindowInteractionStatePropertyId)
End Function
Function GetUiElem(c As CUIAutomation, _
Parent As IUIAutomationElement, _
TypeCondition, _
ValCondition, _
ByVal TreeScope As TreeScope) As IUIAutomationElement
Dim x As Integer, obj As IUIAutomationElement, Condition As IUIAutomationCondition
x = 0
Select Case TypeCondition
Case "Name"
Set Condition = c.CreatePropertyCondition(UIAutomationClient.UIA_NamePropertyId, ValCondition)
Case "AutoId"
Set Condition = c.CreatePropertyCondition(UIAutomationClient.UIA_AutomationIdPropertyId, ValCondition)
Case "Class"
Set Condition = c.CreatePropertyCondition(UIAutomationClient.UIA_ClassNamePropertyId, ValCondition)
Case "CtrlType"
Set Condition = c.CreatePropertyCondition(UIAutomationClient.UIA_ControlTypePropertyId, ValCondition)
Case Else
Set Condition = c.CreateTrueCondition
End Select
Set GetUiElem = Parent.FindFirst(TreeScope, Condition)
End Function