cancel
Showing results for 
Search instead for 
Did you mean: 

How to suppress the SAP GUI when runing a VBA Script?

Former Member
0 Kudos

I have one simple question regarding SAP Scripting. I am using Excel VBA and I would like to either turn off the SAP GUI or suppress the GUI from being displayed to the user while the VBA script is being executed. Is there a command/code that I can use to do this?  Any help will be greatly appreaciated!


I have tried the following code with no luck:

     Set sapcnn = sap.OpenConnection("System Description", False)

     session.findById("wnd[0]").Iconify
     session.TestToolMode = 1



Below is my connection to SAP Scripting code.


    Set sapcnn = CreateObject("Sapgui.ScriptingCtrl.1")

    Set sapcnn = sap.OpenConnection("System Description")

    Set session = sapcnn.Children(0)

Accepted Solutions (1)

Accepted Solutions (1)

stefan_schnell
Active Contributor
0 Kudos

Hello Karim,

welcome in the Scripting Language forum.

Your code works perfect, the Iconify method is a good way to realize an "invisible" window. Here my variant:

Sub Test()

  Dim App As SAPFEWSELib.GuiApplication

  Dim Conn As SAPFEWSELib.GuiConnection

  Dim Sess As SAPFEWSELib.GuiSession

  Set App = CreateObject("Sapgui.ScriptingCtrl.1")

  Set Conn = App.OpenConnection("NSP lokal")

  Set Sess = Conn.Children(0)

  Sess.FindById("wnd[0]").Iconify

  Sess.FindById("wnd[0]/usr/txtRSYST-BNAME").Text = "BAMBI"

  Sess.FindById("wnd[0]/usr/pwdRSYST-BCODE").Text = "secret"

  Sess.FindById("wnd[0]").SendVKey 0

  Stop

End Sub

You can find the system description in the properties of the SAP logon.

Let us know your result.

Cheers

Stefan

Former Member
0 Kudos

Stefan, thank you for taking the time to reply.  Unfortunately the statement "session.FindById("wnd[0]").Iconify" does not hide the SAP GUI from the users it only minimizes the GUI.  I would like the script to run in the background so users do not get confused by the GUI moving by itself.

stefan_schnell
Active Contributor
0 Kudos

Hello Karim,

as I understand you correct: You want to hide an SAP session resp. make the window complete invisible, also from the taskbar. Then you want to control the UI of the invisible window, do your task, in the context of the user's name but without his control and knowledge. I think it is basically not a good idea to do this kind of operation. This scenario sounds more like a task in the backend.

Cheers

Stefan

Answers (0)