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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

SAP VB Script Error

(1) ShareShare
ReportReport
Posted on by 10

I recorded in SAP.
When I clicked Scripts1.vbs file, it's going well replayed.

​ 

But when run in PAD VB Script, it fails with below message. 
(SAP GUI 730 and 770 same result)

C:\Users\OOOO\AppData\Local\Temp\Robin\teozxidxbpc.tmp(2, 4)(null): invalid syntax

 

There is nothing any file in directory AppData\Local\Temp\Robin\ 


Below is script

 

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 = "/NZZZZ0000"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/radP_RAD9").select

session.findById("wnd[0]/usr/ctxtS_UNAME-LOW").text = "199999999"

session.findById("wnd[0]/usr/radP_RAD9").setFocus

session.findById("wnd[0]/tbar[1]/btn[8]").press

session.findById("wnd[0]/tbar[1]/btn[45]").press

session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[4,0]").select

session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[4,0]").setFocus

session.findById("wnd[1]/tbar[0]/btn[0]").press

Anyone can Help me?
Thank you.

I have the same question (0)
  • eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    Do you have SAP running when PAD runs that script? SAP needs to be open and logged in for the scripts to work.
    Atleast thats how I was able to reproduce that error.

     

    The error indicated that there is invalid syntax in row 2 character start position 4: C:\Users\OOOO\AppData\Local\Temp\Robin\teozxidxbpc.tmp(2, 4)(null): invalid syntax
    So problem is right at the start when trying to set SapGuiAuto

  • Lochen Profile Picture
    10 on at

    Yes, Sap is running. 
    So when I clicked .vbs file is work. but PAD is not.
    I copied all script in vbs file to "VBScript Execution" as it is.

    There is something suspicious,
    Our sap application  log in by SLO, previous PAD "click" action, Not "SAP start" action.
    Is it matter in this problem?
    Isn't it OK if SAP is running when VBscript execute?

  • eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    Then I think the problem might be as you suspect something about your SAP. For some reason PADs Run VBScript cant find you SAP GUI. I didn't fully understand how you login but is there a way to open SAP in a different way so maybe it creates SAPgui in your system and PAD actually recognizes it when running the script.

    Someone suggested using CreateObject rather than GetObject

    If Not IsObject(application) Then
     Set SapGuiAuto = CreateObject("SAPGUI")
     Set application = SapGuiAuto.GetScriptingEngine
    End If

    Or just rebooting the system.
    SAP VBScript error while running in PAD - Power Platform Community (microsoft.com)

     

    Is you Power Automate Desktop fairly new version? If its old maybe try updating it.

    Otherwise I would suggest asking for you IT or who ever is maintaining your SAP.

  • Lochen Profile Picture
    10 on at

    When used 

    Set SapGuiAuto = CreateObject("SAPGUI")

    retrun below Error :

     
    "C:\Users\admin\AppData\Local\Temp\Robin\vszhi21dkx.5.tmp(2, 4) Microsoft VBScript Runtime Error: ActiveX component cannot create object: 'SAPGUI'"

    Thanx anyway. ^^

    I'll googling more...

  • LazyAutomator Profile Picture
    6 on at

    Same problem for me. Before the PAD update it worked.  I use a rather old SAP ERP. Trying to run the vbs script using DOS command action does not work either. When PAD is involved, it results in an error. I am out of ideas. 

  • Archy Profile Picture
    83 on at

    is the SAP already open, because you are traying to create a new object. Just connect to it:

    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

    and then your actions. try replacing with this code. 

     

    _____________________________________________________________________________________________

    If my answer helps you solve the problem, please hit the 👍 and accept it as a solution.

  • ohhStudiio16 Profile Picture
    2 on at

    I have the same issue as well. PAD is just skipping over the VBScript completely like its not detecting its open. It worked no issues last week but after a PAD update it is no longer working. My code is aligned with above to connect to it but it doesn't throw any error, it just skips over the step in the flow completely. Any resolvement?

  • eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    Are you sure you have enabled ScriptError variable? 

    eetuRobo_0-1717098193760.png

    It not on by default. Usually if VBscript action runs without any output in the VBScriptOutput variable it has ran into error. So check the ScriptError variable.

    eetuRobo_1-1717098301976.png

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard