Skip to Content
avatar image
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • May 18, 2005 at 07:27 AM

    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,


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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);