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 / 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 2026 Season 1 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 2026 Season 1 on at
     
    Attach that excel and read the excel from actions.
     
    Regards,
    Vishnu Reddy
  • Suggested answer
    CU31080729-3 Profile Picture
    502 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
    4,048 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard