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 / How to pass Excel VBA ...
Power Automate
Suggested Answer

How to pass Excel VBA Macro variable value to power automate desktop

(0) ShareShare
ReportReport
Posted on by 20
Hello,
 
I have created VBA macro and want to pass variable value from that excel to Power Automate desktop flow.
is it possible? Can anyone help me.
I have the same question (0)
  • VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at
     
    I think you got the answer from previous thread right.
     
     
    Regards,
    Vishnu Reddy
  • CU21040728-0 Profile Picture
    20 on at
    Yes, that answer is for pass the variable value from PAD to Macro.
    Now I want to pass the variable value from Macro to PAD.
  • Suggested answer
    VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at
     
    Attach that excel and read the excel from actions.
     
    Regards,
    Vishnu Reddy
  • Suggested answer
    CU31080729-3 Profile Picture
    500 Moderator on at
     
    As per my knowledge there is no directly option available to passed variable value from macro to power automate desktop .
    for that you need to write your variable value into one excel file from macro code and then this value you need to read from PAD .
     

    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!
     
     
  • Suggested answer
    Riyaz_riz11 Profile Picture
    3,893 Super User 2025 Season 2 on at
    Hi,
     
    1. Pass Variable via Command-Line Arguments (Recommended)
     Use Case:
    You trigger Power Automate Desktop flow from VBA and pass your variable (e.g., CustomerID, Amount, FilePath) as a command-line argument.
     How To Do It:
     Step 1: In PAD
    Open your PAD flow.
    At the top, click on "Input/Output variables"
    Create a new Input variable (e.g., MyInputVar)
    Set its type as Text
    Step 2: Use CMD to Run PAD Flow with Variable
    You can trigger PAD from VBA using Shell like this:

    Sub RunPADFlowWithVariable()
        Dim variableValue As String
        variableValue = "HelloFromExcel"
        Shell "C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe -f ""MyPADFlowName"" -i ""MyInputVar=" & variableValue & """", vbNormalFocus
    End Sub
     This runs your PAD flow and sets MyInputVar to "HelloFromExcel"
     2. Use a Temporary Text File
    If the data is complex (like arrays or multiline text), use a shared file.
    VBA writes value to file:
    Sub WriteToTempFile()
        Dim filePath As String
        filePath = "C:\Temp\input.txt"
        Open filePath For Output As #1
        Print #1, "ValueFromExcel"
        Close #1
    End Sub
    PAD reads file:
    Use "Read text from file" in PAD to capture the value.
    3. Use Excel File as the Data Source
    If you're already in Excel, let Power Automate Desktop:
    Open the file
    Read the cell value using "Read from Excel worksheet"
    This is slower but requires no variable passing from VBA.
     
    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

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

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard