SAP GUI Scripting Error, “The Enumerator of the collection cannot find an element with the specified index.”

前端 未结 3 1552
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 11:27

A few weeks ago I generated a script via SAP\'s built in GUI scripting functionality, and then put the vba in an excel document and attached it to a button.

this wo

3条回答
  •  执念已碎
    2021-01-14 11:51

    I know it's old, but probably might help someone else. I don't know the reason for this, out of the blue started having problems with my scripts. I recorded a new operation to see what SAP would write for those actions (since that part of the code is standard for the connection). Same code, same problem.

    Fix (or at least temporary): Change the number of the child being searched. Previous code:

    *Set Connection = Sap_Application.Children(0)*
    

    New code:

    *Set Connection = Sap_Application.Children(1)*
    

    Not sure what the difference is, I know that if you also change the number in this line:

    *Set session = Connection.Children(0) 'This is the line that causes the error*
    

    the execution takes place in the second session, if you do change this one, also have to change the previous line of code.

    Hope it helps!

提交回复
热议问题