I am attempting to control an open SAP GUI Client window through COM in a C# program. The server version is S/4HANA, and the client is the SAP GUI 770 desktop client.
I have a VBA program where this works perfectly. Subsequent code functions as expected:
Set SapGuiAuto = GetObject("SAPGUI")
When attempting what I believe is the equivalent in C#, it does not work.
object o = Marshal.GetActiveObject("SAPGUI");
This is the error message:
System.Runtime.InteropServices.COMException: 'Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))'
I've tried every variant I can think of, and I've run the program as 32 and 64 bit with no change.
Any advice is welcome.