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 Platform Community / Forums / Power Automate / Using PAD variables in...
Power Automate
Suggested Answer

Using PAD variables in VBS script - June 2025 version 2.57

(0) ShareShare
ReportReport
Posted on by 3
Im trying to run a VBS Script embedding string values inside variables from previous steps in PAD but when i try to include it on "Run VBS Script" using ${variable} but its not working. I also tried "${variable}" and %variable% but stil no result.
When the flow gets to the vbs script it just simply ignore it and  its because it doesnt recognize the variable.
 
Has the way to use variables inside VBS script inside PAD has change?
 
I have the same question (0)
  • Suggested answer
    eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at
    What flow type are you using? Power Fx or regular flow? If its Power Fx enabled it should say so at the top left corner


    With Power Fx the variable referencing is ${variable} and with regular flow %variable%
    For making sure the referencing is correct use the PADs variable selector



    Is the variable a text type? If so add quotation marks around the variable. Like so in Power Fx: "${variable}"


    In the variables produced there is ScriptError that is turned off by default. Turn that on to see where the error happens

    Share a screenshot of your flow and also the vbscript for better understanding it.
  • Suggested answer
    Riyaz_riz11 Profile Picture
    3,878 Super User 2025 Season 2 on at
    Hi,
     

    Step 1: Create Your PAD Variables

    Example:

    myName = "John Doe"
    myAge = 30
     

     Step 2: Use “Run VBS Script” Action

    • Double-click "Run VBS Script"

    • Paste your VBS code (see example below)

    • In the “Input variables” section, add:

      • Name: inputName, Value: %myName%

      • Name: inputAge, Value: %myAge%

     Step 3: Write VBS Code Like This:

    ' VBS script
    MsgBox "Name: " & inputName & vbCrLf & "Age: " & inputAge

    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz
  • Suggested answer
    CU31080729-3 Profile Picture
    500 Moderator on at
     
    if you used create flow without power fx then you can try to passed variable with duotes 
    like "%myvariable%"  
     
     
    Thanks & Regards
    Chetan Ninghot
     
    Was this answer helpful?
    If yes, please mark it as the solution by selecting the checkbox in the discussion thread.
    Your feedback motivates me to keep contributing. Thank you!

     
  • VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at
     
    If you can share the screenshot of flow,it would be better to help.
     
    Regards,
    Vishnu Reddy
  • CJ - SVCA Profile Picture
    3 on at
     
    Thank for the response.The final objective of the flow is to extract info from SAP using a SAP Script.
     
    Im new to PAD, but yes Im using Fx flow and follow your instruction of selecting variable from menu.
     
    Structure of the flow
     
    First, I used a box to get input from user to select 2 dates which will be stored in variables. Stored as datetime.
    Variables: Selecteddate and secondselecteddate
     
    Then i convert it to string in mm.dd.yyyy format using a powershell script (variables values recognized without problem):

    $fecha = Get-Date "${SelectedDate}"
    Write-Output  ($fecha.ToString("MM.dd.yyyy").Trim())
     
    Variables: SelectedDateString and SecondSelectedString}
     
    Then i want to run a VBS script setting parameters values based on the inputs.
     
    At the moment Im using this way to declare the values inside the VBS script.
     
    session.findById("wnd[0]/usr/ctxtIT_WADAT-LOW").text = "${SelectedDateString}"
    session.findById("wnd[0]/usr/ctxtIT_WADAT-HIGH").text = "${SecondSelectedString}"
      
    ERROR ON VBS detected: UNTERMINATED STRING CONSTANT
     
    Entire VBS 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 = "vl06f"
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/usr/ctxtIT_WADAT-LOW").text = "${SelectedDateString}"
    session.findById("wnd[0]/usr/ctxtIT_WADAT-HIGH").text = "${SecondSelectedString}"
    session.findById("wnd[0]/usr/ctxtIT_LGORT-LOW").setFocus
    session.findById("wnd[0]/usr/ctxtIT_LGORT-LOW").caretPosition = 10
    **session.findById("wnd[0]/usr/btn%IT_LGORT%APP%-VALU_PUSH").press
    session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL_255-SLOW_I[1,0]").text = "1001"
    session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL_255-SLOW_I[1,1]").text = "2001"
    session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL_255-SLOW_I[1,2]").text = "2220"
    session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL_255-SLOW_I[1,2]").setFocus
    session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL_255-SLOW_I[1,2]").caretPosition = 4
    session.findById("wnd[1]/tbar[0]/btn[8]").press
    session.findById("wnd[0]/tbar[1]/btn[8]").press
    session.findById("wnd[0]/tbar[1]/btn[18]").press
    session.findById("wnd[0]/tbar[1]/btn[33]").press
    session.findById("wnd[1]/usr/lbl[1,12]").setFocus
    session.findById("wnd[1]/usr/lbl[1,12]").caretPosition = 7
    session.findById("wnd[1]").sendVKey 2
    session.findById("wnd[0]/tbar[1]/btn[43]").press
    session.findById("wnd[1]/usr/ctxtDY_PATH").text = "My internal address in the computer"
    session.findById("wnd[1]/usr/ctxtDY_PATH").setFocus
    session.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 53
    session.findById("wnd[1]/tbar[0]/btn[0]").press

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

    Thank for the added information. I would also check which row specifically goes to error. The ScriptError should tell it after .tmp and inside parentheses


    That would tell if only one of those string variables gives error. 
    I didn't see the SecondSelectedString variable in your variable list. Or if its this then make sure you also convert that to string from datetime:


    One problem might be in SAP that you are trying to insert value into its field that its not accepting. I would troubleshoot this by inserting those values hardcoded in the vbscript
    So change these rows:
    session.findById("wnd[0]/usr/ctxtIT_WADAT-LOW").text = "${SelectedDateString}"
    session.findById("wnd[0]/usr/ctxtIT_WADAT-HIGH").text = "${SecondSelectedString}"
    To:
    session.findById("wnd[0]/usr/ctxtIT_WADAT-LOW").text = "08.06.2025"
    session.findById("wnd[0]/usr/ctxtIT_WADAT-HIGH").text = "18.06.2025"
     

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard