Connecting Excel 2010 and SAP (on Windows 64Bit)
I have an excel macro, that connects to SAP (and executes transaction SOLAR01).
This macro is running in Excel 2010 and was all OK, until I received a new PC, now with Windows 7, 64 Bit.
Now the connection to SAP is not created anymore.
Error message is:
"Run-Time Error 614: The enumerator of the collection cannot find en element with the specified index"
This is the code snippet with the error:
Dim application As Object
Dim sapguiauto As Object
Dim connection As Object
Dim session As Object
Set sapguiauto = GetObject("SAPGUI")
Set application = sapguiauto.GetScriptingEngine
Set connection = application.Children(0)
Set session = connection.Children(0)
session.findById("wnd/tbar/okcd").text = "/nsolar01" 'Aufruf der Transaktion
The red part is causing the error. The Children-enumeration is of size 0. As well as the session enumeration.
Therefore, I cannot get the session and go on in the code.
According to the documentation and as previous experience showed, it worked fine on Windows 7 (32 Bit).
In Windows 7 (64 Bit) it is not possible?!
I read somewhere, that the 64 Bit are the root cause for the issue.
Does anyone have an idea, how to get the session-enumeration in Windows 7, 64 Bit??
PS: I checked the following solution without success: http://scn.sap.com/thread/2090988.
The solution turned out to be quite easy and is not related to windows.
After a restart of the system, a parameter was not correct.
The profile parameter sapgui/user_scripting must be set to “TRUE” --> enabling scripting.