Trigger a Power Automate Flow Using VBA in Excel
You can trigger a Power Automate Flow from VBA in two ways:
1️⃣ Using an HTTP Request (via Power Automate's HTTP Trigger)
2️⃣ Using Power Automate Desktop (via UI Automation or Command Line Execution)
1. Trigger Power Automate Flow via HTTP Request
Steps to Follow:
Create a Power Automate Flow with an HTTP Trigger
- Go to Power Automate.
- Click Create > Automated Cloud Flow.
- Select "When an HTTP request is received" as the trigger.
- Click "Save", and Power Automate will generate a POST URL.
Copy the HTTP Request URL
- This URL is needed in VBA to trigger the flow.
Use VBA to Call the Power Automate Flow
- Add this VBA code in your Excel file:
How It Works:
✅ Triggers the Power Automate flow using an HTTP POST request.
✅ Sends JSON data (optional) to Power Automate.
✅ Checks for success or failure (HTTP status 200 or 202).
2. Trigger Power Automate Desktop (PAD) Flow Using VBA
If you want to trigger a Power Automate Desktop (PAD) flow, you can use a Shell command.
Steps:
Create a PAD Flow
- Open Power Automate Desktop.
- Create a new flow.
- Click "Run URL" and copy the PowerShell command.
- To get "Run URL" click on insist button and you will find the URL.
Use VBA to Run Power Automate Desktop
✅ Triggers Power Automate Desktop without an HTTP request.
✅ Good for local automation workflows.
Which Method is Best?
Method | Use Case | Works on Cloud? |
---|---|---|
HTTP Request (Method 1) | Best for triggering cloud-based Power Automate flows from Excel | ✅ Yes |
Power Automate Desktop (Method 2) | Best for triggering local automation tasks on your PC | ❌ No |
No comments:
Post a Comment