'-Begin-----------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Global Variables----------------------------------------------------
Dim gColl()
'-Function FindAllByType----------------------------------------------
Function FindAllByType(Obj, strType)
'-Variables-------------------------------------------------------
Dim cntObj, i, j, Child
On Error Resume Next
cntObj = Obj.Children.Count()
If cntObj > 0 Then
For i = 0 To cntObj - 1
Set Child = Obj.Children.Item(CLng(i))
FindAllByType Child, strType
If UCase(Child.Type()) = UCase(strType) Then
ReDim Preserve gColl(j)
Set gColl(j) = Child
j = j + 1
End If
Next
End If
On Error Goto 0
FindAllByType = gColl
End Function
'-Function FindAllByType----------------------------------------------
Function FindAllByTypeEx(Obj, lngType)
'-Variables-------------------------------------------------------
Dim cntObj, i, j, Child
On Error Resume Next
cntObj = Obj.Children.Count()
If cntObj > 0 Then
For i = 0 To cntObj - 1
Set Child = Obj.Children.Item(CLng(i))
FindAllByTypeEx Child, lngType
If Child.TypeAsNumber() = lngType Then
ReDim Preserve gColl(j)
Set gColl(j) = Child
j = j + 1
End If
Next
End If
On Error Goto 0
FindAllByTypeEx = gColl
End Function
'-Sub Main------------------------------------------------------------
Sub Main()
'-Variables-------------------------------------------------------
Dim SapGuiAuto, application, connection, session, Coll, i
Dim OutText
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
Erase gColl
Coll = FindAllByType(session, "GuiLabel")
For i = 0 To UBound(Coll)
OutText = OutText & Coll(i).ID() & vbCrLf
Next
Erase gColl
Coll = FindAllByTypeEx(session, 31) 'GuiTextField
For i = 0 To UBound(Coll)
OutText = OutText & Coll(i).ID() & vbCrLf
Next
MsgBox OutText
End Sub
'-Main----------------------------------------------------------------
Main
'-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
11 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
3 |