Option Explicit
Sub Main()
Dim CATIA
Set CATIA = GetObject(, "CATIA.Application") ' get CATIA Application
Dim doc
Set doc = CATIA.ActiveDocument
Dim sel
Set sel = doc.Selection
sel.Clear
sel.Add doc.Sheets.ActiveSheet.Views.ActiveView
CATIA.StartCommand "Properties"
Dim winAutomation As CUIAutomation
Set winAutomation = New CUIAutomation
Dim desktop As IUIAutomationElement
' get reference to the root element (desktop)
Set desktop = winAutomation.GetRootElement
Dim allWindowsCond As IUIAutomationCondition
' retrieves a predefined condition that selects all elements
Set allWindowsCond = winAutomation.CreateTrueCondition
Dim childs As IUIAutomationElementArray
' find all elements & put them into element array
Set childs = desktop.FindAll(TreeScope_Children, allWindowsCond)
Dim i As Long, currChild As IUIAutomationElement
Dim catiaWindow As IUIAutomationElement
' loop through all element and find CATIA by window name which contains "CATIA V5" string
For i = 0 To childs.Length - 1
Set currChild = childs.GetElement(i)
If InStr(currChild.CurrentName, "CATIA V5") Then
Set catiaWindow = currChild ' set main catia window
End If
' Debug.Print currChild.CurrentName, currChild.CurrentClassName
Next
Dim propWinCond As IUIAutomationCondition
Set propWinCond = winAutomation.CreatePropertyCondition(UIA_NamePropertyId, "Properties")
Dim propWin As IUIAutomationElement
'wait for Graph window to open and get it
Do
Set propWin = catiaWindow.FindFirst(TreeScope_Children, propWinCond)
' do not freeze application in case of infinite loop
DoEvents
Loop While propWin Is Nothing
Dim comboCond As IUIAutomationCondition
Set comboCond = winAutomation.CreatePropertyCondition(UIA_ControlTypePropertyId, UIA_ControlTypeIds.UIA_ComboBoxControlTypeId)
Dim comboElem As IUIAutomationElement
Set comboElem = propWin.FindFirst(TreeScope_Descendants, comboCond)
MsgBox comboElem.GetCurrentPropertyValue(UIA_PropertyIds.UIA_ValueValuePropertyId)
End Sub