cancel
Showing results for 
Search instead for 
Did you mean: 

how to use createobject("SAPGUI") in csharp?

Former Member
0 Kudos

I want to control the SAPGUI in Csharp instead of VB.

Can anyone give me a sample using Csharp? or delphi?

it seems that I must know the exactly class type instead of using object.

Accepted Solutions (0)

Answers (1)

Answers (1)

Christian_Cohrs
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Keynes,

I haven't tried this myself, but I guess the problem is not in the creation of the object but rather in the type safe assignment of the resulting COM interface. If you import the type library from sapfewse.ocx you can work with the interfaces. The GuiApplication interface is _Dsapfewse (not so nice, I know), the GuiSession interface is ISapSessionTarget and so on. You might have to use OLE View or a similar tool to find all of them.

I'm not sure what happens when you create a .NET assembly out of this, probably some name mangling.

Best regards,

Christian

Former Member
0 Kudos

yes, you are right. I need to know the object type of SAPGUI in C# instead of using variant in VB.

I will try the interface you mentioned.

Thank you.

Former Member
0 Kudos

Yes, i have given a try to the above method, and it worked.

SapGui.ScriptingCtrl.1 is the type that is mentioned in the sapgui scripting api.

Type objType = Type.GetTypeFromProgID("SapGui.ScriptingCtrl.1");

Object objApplication = Activator.CreateInstance(objType);