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 / Invalid syntax of VBSc...
Power Automate
Suggested Answer

Invalid syntax of VBScript for SAP

(1) ShareShare
ReportReport
Posted on by 4

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%vDocumentNo%

If IsObject(WScript) Then

   WScript.ConnectObject session,     "on"

   WScript.ConnectObject application, "on"

End If

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

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_ARL_LINK"

session.findById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").hierarchyHeaderWidth = 388

session.findById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").selectItem ""%vDocumentNo%"","HITLIST"

session.findById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").ensureVisibleHorizontalItem ""%vDocumentNo%"","HITLIST"
VBScriptError PAD.PNG
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,975 Super User 2026 Season 2 on at
    Hi
     
    Did you notice you have this variable here next to the end if
  • Suggested answer
    eetuRobo Profile Picture
    4,607 Super User 2026 Season 2 on at
    As @FLMike pointed out you should remove the %vDocumentNo% after the second to last End if. 

    What gives the syntax error is percent signs in the SAP elements (rows 31 and 33). Since PAD reads percent signs as variable starts and ends signs it will give syntax error since it thinks you didn't close the variable referencing. Add another percent sign and it reads it as one. Like so:


    Also make sure its intentional to have two bouble quotes around vDocumentNo -variable

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 377

#2
11manish Profile Picture

11manish 292 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 128

Last 30 days Overall leaderboard