Thanks, i have used your code to develop a work around,
Problem:
VBA will crash the SapGui when interacting with certain items contained in a Tab Strip Sub Screen,
Solution:
VBS scripts do not cause this behavior use VBA to Write VBS Script file and launch the file using the ShellandWait function CPearson Shell And Wait
Section in VBA Code
- Q = 0
- For i = 0 To session.findById("wnd[0]/usr").Children.Count() - 1
- ReFindTabs:
- Set Tabs = session.findById("wnd[0]/usr").Children.Item(CLng(i))
- If Tabs.Type() = "GuiTabStrip" Then
- For J = Q To Tabs.Children.Count() - 1
- Tabs.Children.Item(CLng(J)).Select
- EmptyTextFields session
- Call ShellAndWait("cscript ""C:\Test\TabStrip.VBS""", 0, vbHide, PromptUser)
- Q = Q + 1
- GoTo ReFindTabs
- Next
- End If
- Next
VBS Code File (Thanks to Stefan Schnell for the content)
- If Not IsObject(application) Then
- Set SapGuiAuto = GetObject("SAPGUI")
- Set application = SapGuiAuto.GetScriptingEngine
- End If
- If Not IsObject(connection) Then
- Set connection = application.Children(SapApp.Children.Count - 1)
- End If
- If Not IsObject(session) Then
- Set session = application..Children(SapApp.Children.Count - 1).sessions(SapApp.Children(SapApp.Children.Count - 1).sessions.Count - 1)
- End If
- If IsObject(WScript) Then
- WScript.ConnectObject session, "on"
- WScript.ConnectObject application, "on"
- End If
- Dim cntObj, i, 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))
- EmptyPushEntries Child
- If InStr(Child.ID(), "/usr/") Then
- If InStr(Child.ID(), "-VALU_PUSH") Then
- If Child.IconName() = "BGMORE" Then
- Child.Press()
- session.findById("wnd[1]").sendVKey 16
- session.findById("wnd[1]").sendVKey 8
- End If
- End If
- End If
- Next
- End If
- On Error Goto 0
- End Sub