ERROR IN INVOKE CODE vbs code

Hi all,

I have this activity “Invoke code” with into VBS code, but when we try to run I have an error:
In attached the code vbs and the workflow
Main.xaml (9.1 KB)

Any suggestion?

Best Regards,
S.

Hi @salvatore.quimi ,

I wasn’t able to open your file. Can you elaborate a bit more on what you’re trying to do? Also, Can you share a screenshot of the error?

HI,

InvokeCode activity supports not VBS but VB.net and C#. So, can you try to use InvokeVBscript activity instead?

Regards,

Hi @Edwin_Barahona,

the error is this:

And the code is:

If Not IsObject(application) Then
SET SapGuiAuto = GetObject(“SAPGUI”)
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, “on”
WScript.ConnectObject application, “on”
End If
session.findById(“wnd[0]”).maximize
session.findById(“wnd[0]/tbar[0]/okcd”).text = “su01”
session.findById(“wnd[0]”).sendVKey 0
session.findById(“wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME”).text = “xxxx”
session.findById(“wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME”).caretPosition = 6
session.findById(“wnd[0]”).sendVKey 0
session.findById(“wnd[0]/tbar[1]/btn[7]”).press
session.findById(“wnd[0]/usr/tabsTABSTRIP1/tabpACTG”).select

Any suggestion?

Best Regards,
S.

In plus the function require this one:

image

Hi @salvatore.quimi ,

I didn’t see the detail that is a VBscript (SAP script in your case), as the error says some statements are not supported by the compiler.

Instead, as @Yoichi also mentioned try one of these:

  • Use Invoke VBScript

  • Use Invoke VBA or dump the code into an excel macro and use Run Macro, both of these solutions require Excel Scope and enable the appropriate security settings in Excel.

1 Like

Thanks @Edwin_Barahona for your explanation, the Invoke VBA is for excel but in my case I would need SAPGUI.

Is there anyone who knows how to fix statements are not supported by the compiler?

@Yoichi I have already used Invoke VBS script activity but I need an activity where you can write the code as “invoke code” and not an activity that calls a file with the code inside.

Any ideas? thanks in advance

Best Regards,
S.

@salvatore.quimi, you will need to essentially convert your script from vba to vb.net, I found a few resources that may contribute to build a customized solution.

https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/babdf65f4d0a4bd8b40f5ff132cb12fa.html?version=760.00

Also, you could try using custom libraries from the marketplace

Thank you for your suggestion!!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.