cancel
Showing results for 
Search instead for 
Did you mean: 

VbScript Runs Fine for One User, but Fails for Another

0 Kudos

I put together an Excel Macro combining VBScript and VBA. Some adjustments are still needed, but for the most part it runs well and at least one other user than myself have no issues. However, a third user gets the following error at execution: Run-time error '614': The enumerator of the collection cannot find the an element with the specified index.

The debug specifically highlights "Set session = Connection.Children(0)"

If Not IsObject(GetDataDump) Then

Set SapGuiAuto = GetObject("SAPGUI")

Set GetDataDump = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(Connection) Then

Set Connection = GetDataDump.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 GetDataDump, "on"

End If

I don't think the problem is with the code, because I literally run the program without issue on my machine before and after he gets the error message, no changes. His SAP Setting have Scripting enabled, so I don't know where else to look. Any ideas?

Update: Last night I took my laptop home, and on my home WiFi, I received the same error as above, even though I was already working in SAP. At work, I work on the exact same laptop, but the internet is a direct connection. I don't think this is a securities issue, because there was no issue accessing and working in SAP except with this Macro.

Update 2: User 1 (Me), User 2 (Coworker 1), User 3 (Coworker 2), User 4 (Coworker 3), and Machine 5 (General Use Laptop in Meeting Room)

Tuesday:

User 1 and User 2 have no issues using the macro to connect to SAP and perform all functions.

User 3 was able to access the program, but an error was thrown at the first export instance. He had not confirmed his choice of Spreadsheet file format for exporting as default, and I have not included an Error Handling for the situation. I had him check the box, end the Excel Macro, completely close and reopen SAP, then retry the Macro. User 3 then received the Run Time Error 614.

User 4 continues to receive the Run Time Error 614.

Wednesday:

Same situation for all. Machine 5 is successfully used to execute the Macro.

User 3 tests the program in the late afternoon, and is successful. He does not have the opportunity to tell me until today, Thursday.

Thursday:

User 4 is finally able to execute the program, but is halted at the same points as User 3 on Tuesday.

User 1 and User 2 use the program throughout the day without issue.

User 1 is working late, and received Run Time Error 614. Skipping lines of code do not resolve. Reloading Excel file does not resolve. Closing and reopening SAP does not resolve. Restarting computer resolves current issue. The macro is running as I type this.

If you are receiving the exception, "Run-time error '614': The enumerator of the collection cannot find the an element with the specified index", try closing out of everything and restarting your computer. I have more tests to run to confirm, and I have not been able to verify my internal SAP settings, as recommended by some others on similar posts. If anyone here knows anything, I still need help with this issue.

script_man
Active Contributor
0 Kudos

It's all very confusing. Above all, you don't see Excel transport in the example, but we're talking about it. It would be better if you could see the complete code.

0 Kudos

Hey Script Man, thank you for the reply. However, this error is occurring when Excel is attempting to connect to SAP, long before anything occurs with the transport. If I'm missing your point, a more complete code can be found here at another of my questions, which I credited you for the solution.

Prevent or Close Exported Files - From SAP GUI to Excel | SAP Community

Accepted Solutions (0)

Answers (0)