First my test code
Sub mytest2()
If Not IsObject(MyApplication) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set MyApplication = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = MyApplication.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(Wscript) Then
Wscript.ConnectObject session, "on"
Wscript.ConnectObject MyApplication, "on"
End If
Dim MyTableStr As String
Dim MyTable As Variant
MyTableStr = "wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107/tabsTS_1100/tabpVGUE/ssubSUB_AUFTRAG:SAPLCOVG:3010/tblSAPLCOVGTCTRL_3010"
Set MyTable = session.findById(MyTableStr)
MyTable.VerticalScrollbar.Position = MyTable.VerticalScrollbar.Position + 1
Debug.Print MyTable.VerticalScrollbar.Position & " position"
This code will increase the table's vertical position and then fail on the debug.print line with error "Object doesn't support this action" Run-time error 445
If I add again the line
Set MyTable = session.findById(MyTableStr)
Between the .position line and the debug.print line, it works and the position gets printed.
Why does this happen ?