-1

The enumerator of the collection cannot find en element with the specified index.

I get the above error on line number of 3 of the following code:

Set SapGuiAuto  = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
Set connection = application.Children(0)

How to check size of application.Children?

suyash ghuge
  • 95
  • 2
  • 13
  • The syntax for returning the number of elements in an array is `UBound(ArrayName[,dimension])`. The dimension is only needed when dealing with multidimensional arrays. I know nothing about SAP, but when I see `Children` I suspect there may also be a `Children.Count()` function, but that is speculation on my part. – Rno Aug 11 '20 at 22:10
  • You should probably also check if `SapGuiAuto.GetScriptingEngine` actually returns something (`If application Is Nothing` ...) – Rno Aug 11 '20 at 22:20

1 Answers1

1

Probably the SAP (SAP Logon/SAP GUI) are not open.

But if you want, try:

ChildCount = application.Children.Count