0

I'm working with VBA and GuiXT separated and now I'm trying to use the SAP GUI VBA integration instead, but i think it's not working because I'm missing a permission.

I tried the code I've found in this thread:

Sub test()
    Dim SapGuiAuto As Object
    Dim SAPApp As Object
    Dim SAPCon As Object
    Dim session As Object

    Set SapGuiAuto = GetObject("SAPGUI")
    Set SAPApp = SapGuiAuto.GetScriptingEngine
    Set SAPCon = SAPApp.Children(0)
    Set session = SAPCon.Children.ElementAt(0)

    SAPCon.FindById("wnd[0]").Maximize
End Sub

It runs and SAP informs me that a script tries to connect to SAP, but the line Set session = SAPCon.Children.ElementAt(0) gives me error 614: "The enumerator of the collection cannot find en element with the specified index".

So I googled and found out, that I'm missing the option "Script recording and playback" in SAP, it's greyed out. And i googled further and I found out, that I'm missing the permission to record or playback a script. Because of that I'd like to know: if I don't have the permission in SAP to record or playback a script, then that's the reason for my not working VBA code, right?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Yenne
  • 1
  • Yes, if the situation is as you described. In case gui scripting is disabled by the admin then you will get that error message. But your code contains an error in the following line anyway. The line `SAPCon.FindById("wnd[0]").Maximize` should be `session.FindById("wnd[0]").Maximize`. – Storax Apr 21 '22 at 14:27
  • Thank you, I wasn't sure about that line. Then I have to request more permissions for the task, because I can't use the GUI integration as well as RFC and doing the whole task with GuiXT would be a mess. – Yenne Apr 21 '22 at 14:49
  • @Storax It's worth an answer. – Sandra Rossi Apr 21 '22 at 16:45
  • [Reading](https://help.sap.com/doc/97d2d0bc2ed248a4a85a0bec608704f8/760.01/en-US/sap_gui_scripting_sec_guide.pdf) on SAPGUI scripting security – Storax Apr 21 '22 at 19:01
  • Short [docu](http://winshuttle-help.s3.amazonaws.com/transaction/en/ts-adv-guide/10.x/4119.htm#gsc.tab=0) how to enable it on server and client side – Storax Apr 21 '22 at 19:04
  • @Sandra Rossi If the scripting was disabled on the SAP server which is the default the OP needs to talk with basis and ask them to set the profile parameter sapgui/user_scripting to TRUE – Storax Apr 21 '22 at 19:11

0 Answers0