Skip to Content
avatar image
Former Member

Excel Closes SAP at End of Sub

Hi All, thank you for the help in advance.

I have written Excel macros that use VB to control SAP, and when they reach the end of the subroutine, SAP closes. Is there a way to prevent this from happening?


Thanks!

Alex

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jun 10, 2014 at 10:10 PM

    Hello.

    Can you post your code to understand how you adopt SAP from Excel VBA?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Dear Alex,

      I noticed you used the CreateObject("SAPGUI.ScriptingCtrl.1") method at the beginning of the script, which I believe causes all the issues you mentioned, including the missing graphics and buttons. This is based on my 'experiment' on this method which you can read here: along with discussions on the different methods to connect Excel to SAP using VBA.

      My recommended method is to start saplogon.exe manually or by inserting shell command in your VBA codes and use the GetObject("sapgui") method instead.

      Thanks,

      Sayuti