Get our FREE VBA eBook of the 30 most useful Excel VBA macros.

Automate Excel so that you can save time and stop doing the jobs a trained monkey could do.

Claim your free eBook


How to run Excel macros from Power Automate Desktop

Power Automate Desktop is a Microsoft tool for automating processes in a desktop environment. It’s a really powerful tool, but suffers from one significant drawback… it has limited Excel actions. However, Microsoft has given us the ability to run Excel macros from Power Automate Desktop; therefore, this gives us the power to do almost anything we like with Excel. So, that’s what we are looking at in this post; how to run Excel macros from Power Automate Desktop.

Power Automate Desktop is a free download for Windows 10 and natively available in Windows 11. So, there is a good chance you already have it, or could get it by talking nicely to your IT department.

Download the example file: Click the link below to download the example file used for this post:

These are simple macros to demonstrate the process.

Watch the video

Watch on YouTube

Getting started with Power Automate Desktop

Let’s start by opening the Power Automate Desktop application; it should be searchable from the search box.

Find Power Automate Desktop

When Power Automate Desktop starts, if you’ve not created a flow before, you may have the screen below.

Create new Flow in Power Automate Desktop

Click the New Flow button.

The Build a Flow dialog box opens. Give your flow a name, then click Create.

Give the flow a new name

The flow edit view is laid out as follows:

  • Actions (right pane) – This is a list of the individual actions which Power Automate makes available.
  • Flow (middle section) – This is where we place our actions to create a flow.
  • Variables (left pane) – This is where we create variables, or we can access the variables created automatically by other actions in the flow.
Power Automate Desktop first view

Building a flow to run macros

Let’s build a flow to run a macro from the example workbook.

Action #1: Launch Excel

First, we need to open an instance of Excel.

Expand the Excel section in the Actions pane. Click, drag, and drop Launch Excel into the flow.

Click, drag and drop launch Excel into flow

In the Launch Excel dialog box, change the Launch Excel drop-down list to and open the following document.

Enter the document path (we can click on the document icon to navigate to the workbook and select it).

When finished, click Save.

Launch Excel Dialog Box

In the screenshot above, I am opening a workbook called Macro Workbook.xlsm.

This action also creates a flow variable called ExcelInstance which refers to this specific instance of Excel.

Action #2: Run Macro

Next, we want to run the macro.

Expand the Excel > Advanced section, and drop the Run Excel macro action into the flow.

The Run Excel macro dialog box opens.

The ExcelInstance variable created in the previous step is automatically included. If we have multiple Excel instances in our flow, select the correct instance from the drop-down list. The % around the value indicates this is a variable and not a text string.

Select the macro to run

Enter the Macro name, then click Save.

Each launch of Excel can only include a single workbook. Therefore, we do not need to declare the workbook’s name when providing the macro name.

In the screenshot above, the macro I am running is called RunThisMacro.

Action #3: Close the workbook

Finally, let’s close the instance of Excel we previously opened.

Add the Close Excel action into the flow. In the dialog box, select the Before closing Excel option which meets your scenario. Then, click Save.

Power Automate Desktop action to close the workbook

Review the flow

The flow now looks like this:

Flow after all actions added

Saving the flow

Click the Save button at the top of the window.

Running the flow

Now we are ready to run our flow. There are various ways to do this:

Running macros with arguments

When writing reusable macros, we may include arguments to be usable in many scenarios.

We can run macros with arguments from Power Automate Desktop by separating each argument with a semi-colon ( ; ).

Run macro with arguments

In the screenshot above, the macro RunThisMacroWithArguments has an argument of Hello World.

Working across workbooks

When Power Automate Desktop launches Excel, it creates a separate instance of the application containing a single workbook. As a result, we cannot easily work with multiple Excel files in Power Automate. However, macros can open other workbooks in the same instance. Therefore, using macros in this way gives us opportunities for Excel automation that are not available in Power Automate Desktop alone.

Conclusion

Power Automate Desktop has a lot of power for integration across applications, but has limited Excel actions. However, by running macros from Power Automate, we have access to anything that macros can do while still leveraging the Power Automate Desktop functionality.

Related Posts:


Headshot Round

About the author

Hey, I’m Mark, and I run Excel Off The Grid.

My parents tell me that at the age of 7 I declared I was going to become a qualified accountant. I was either psychic or had no imagination, as that is exactly what happened. However, it wasn't until I was 35 that my journey really began.

In 2015, I started a new job, for which I was regularly working after 10pm. As a result, I rarely saw my children during the week. So, I started searching for the secrets to automating Excel. I discovered that by building a small number of simple tools, I could combine them together in different ways to automate nearly all my regular tasks. This meant I could work less hours (and I got pay raises!). Today, I teach these techniques to other professionals in our training program so they too can spend less time at work (and more time with their children and doing the things they love).


Do you need help adapting this post to your needs?

I'm guessing the examples in this post don't exactly match your situation. We all use Excel differently, so it's impossible to write a post that will meet everybody's needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site), you should be able to adapt it to your needs.

But, if you're still struggling you should:

  1. Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
  2. Ask the 'Excel Ninja' in your office. It's amazing what things other people know.
  3. Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it's clear and concise.  List all the things you've tried, and provide screenshots, code segments and example workbooks.
  4. Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.

What next?
Don't go yet, there is plenty more to learn on Excel Off The Grid.  Check out the latest posts:

2 thoughts on “How to run Excel macros from Power Automate Desktop

Leave a Reply

Your email address will not be published. Required fields are marked *