cancel
Showing results for 
Search instead for 
Did you mean: 

SAP GUI Scripting with VB.NET

Former Member
0 Kudos

I try to write VB.NET application using SAP GUI Scripting classes. Two first lines of the code below attaches SAPLogOn to the script. It works OK. When I try to set object "connection" ( third line)I receive an error.

"An unhandled exception of type 'System.InvalidCastException' occurred.Specified cast is not valid"

SapGuiAuto = GetObject("SAPGUI")

application = SapGuiAuto.GetScriptingEngine

connection = application.Children

Maybe somebody knows how to write that code properly?

In VB6 there is no problem. Third line looks like:

connection = application.Children(0)

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I wrote those lines and they works

SapGuiAuto = GetObject("SAPGUI")

application = SapGuiAuto.GetScriptingEngine

connection = application.OpenConnection(<<System Name String>>, True, False)

session= connection.Children.Item(0)

0 Kudos

Is this thread still active, I would want to know if there is an official library that was imported on the .Net project and where did you guys downloaded it.