web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / SAP VBScript error whi...
Power Automate
Answered

SAP VBScript error while running in PAD

(0) ShareShare
ReportReport
Posted on by 393
Dear Power Automate Desktop Experts, I encountered an error when I'm trying to run a very simple VBScript in Power Automate Desktop:
C:\Users\WAng26\AppData\Local\Temp\Robin\nx5bq0v00fa.tmp(2, 1) (null): Invalid syntax
 
The exact same VBScript can run perfectly when I execute the .vbs file. The VBScript is per below:
 
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 = "/nLT24"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtT2_LGNUM").text = "140"
session.findById("wnd[0]/usr/ctxtT2_MATNR-LOW").text = "*"
session.findById("wnd[0]/usr/ctxtT2_MATNR-LOW").setFocus
session.findById("wnd[0]/usr/ctxtT2_MATNR-LOW").caretPosition = 1
 
Immediate help is much appreciated.
I have the same question (0)
  • fraenK Profile Picture
    2,125 on at

    Did you try using CreateObject instead of GetObject?

    https://help.sap.com/viewer/b47d018c3b9b45e897faf66a6c0885a8/760.03/en-US/a020c8f8cfaf48ec9b579d5961889639.html

  • Verified answer
    JAWL Profile Picture
    393 on at

    Hi @fraenK the "bug" (derived from PAD update) was fixed after I restarted my laptop. 

  • mikkoKarkkainen Profile Picture
    2 on at

    I Have this same error using Windows 10 Enterprise for Virtual Desktops and restarting did not solve it. All VBScripts in PAD fail with the same error.

  • asbkr Profile Picture
    22 on at

    Did anyone solve this?

    I got the same problem today. All of a sudden I can't run any VBscripts in PAD which relates to SAP GUI. They all return af similar error to this: C:\Users\Username\AppData\Local\Temp\Robin\nx5bq0v00fa.tmp(2, 4) (null): Invalid syntax.

    I have tried to restart the server already. The scripts works fine when I run them with SAPs own script tool and if I run them with Microsoft Windows Based Script Host, so there is nothing wrong with the code. 

  • JAWL Profile Picture
    393 on at

    Can you restart your laptop? Normally after PAD updated, you need to restart the laptop.

  • asbkr Profile Picture
    22 on at

    I am running PAD from one of our servers, but yes, have restarted both the server and my laptop and I still get the same error. 

  • asbkr Profile Picture
    22 on at

    I found a solution.
    In my company we login to SAP with SSO through another portal (in a browser). I got the admin to changed login method to manual password and username and used PAD's own funtion "Open Sap Connection" to open the SAP GUI. When I login like that everything works. 

    So I seems that PAD can only connect/detect SAP if it gets to open a SAP Connection 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 474

#2
11manish Profile Picture

11manish 268

#3
David_MA Profile Picture

David_MA 243 Super User 2026 Season 1

Last 30 days Overall leaderboard