Power Automate: Automate your desktop chore with Power Automate Desktop
Hi everyone, nice to meet again we continue to sharing information about Power Platform members. Today, I will share some exciting things about Power Automate Desktop. But first, if you heard that it first time please check on it official Microsoft documentation: Introduction to desktop flows
Power Automate Desktop in a nutshell
Power Automate Desktop is an application that easily automate your repetitive tasks which is required click on or move on it to another path. For an example, you need to move more than a hundred excel sheet from to another folder, you can easily achieve that via Power Automate Desktop.
Let’s start our example that we will do today
In our scenario, we have five different word files that are required to move the data to excel sheet.
As you can see, each table members which are placed on word file, should move to excel file sequentially. Order Number match to Order Number column, Your Full Name match Name, Cookie Type & Quantity match Order Quantity etc.
Keep in mind that each item that should processed as it is, created as table. Thus, flows steps are recognized by automate desktop app.
Let’s start Create Power Automate Desktop App
Click on create new flow and name it:
After creating a new desktop application project, you can see all actions on the left side of the screen, Main content middle of the screen and variables right of the screen which are placed as we see
Creating Flow Steps
Get files in folder
First steps, retrieve all of these files, in order to do that click on folder action on left hand side of the screen and select Get files in folder action
There are different inputs for this action. Let’s quick overview what those are mean:
Folder: Specify the folder path which is required to proceed.
File filter: If I have different file types that were unrelated for this form, file filter let filter them out.
Click on save and continue.
After saved the scope, you can see the first step as it below.
When you look at variables section, you can notice that is added one variable, it means it hold of the files which is specified if you have a filter, otherwise hold as it is.
Launch Excel
Now, time to open excel file:
You can follow these steps: Actions -> Excel -> Launch Excel
Let’s check variables again:
Launch Excel: You should select and open the following document option from dropdown list.
Document Path: Add document where you store at
Add For each Loop
In order to get all information which is placed on the files, need to add loop. I want to setup for each loop for this step:
We want to process on the files, so need to add Files as variable. After added this steps, pleas check variables pane again.
Keep in mind that, all steps which is required looping should add between For each , end scope:
After added for each loop, I want to take the current item and extract it, we are going to use this one file to extract all of the details: the reason for this is we are going to identify UI elements and make sure that they are the same across all files.
To rename the file, select and add Rename file(s) action between the For each and end scope.
File to rename: The file path need to rename. You should add it as variable as known as %CurrentItem% variable.
Rename scheme: Set new name
New File Name: Extract
If file exists: Overwrite. Every time it runs through this loop it is going to rename the file to extract so it is going to exist the second time it runs through all the way up through the last time it runs so that’s why we select as overwrite.
Run Application
Now, we should run the application to open related files within loop. Search on Run application action on Actions pane.
Before we add this steps I will show you a quick trick how you can get the application path from your computer:
1- Open Search bar any type as Word
2- Right click on Word icon and click on open file location
3-Click on WINWORD with Shift+ RIGHT CLICK combination and select Copy as Path (You can not see if you only right click without the combination)Well, back to Power Automate then
Paste Application Path where we copy this.
Don’t forget to remove double quotes from Application Path value
Also, command line argument should added the file that will we named as Extract within the same path folder. Add /t beginning of the path and add double quotes over here.
As a next step, create some UI elements within out document. Let’s open Coffee Order folder just copy one of them the word file and paste the same folder and rename the file as an Extract
Let’s open up the new file and back to Power Automate Desktop and indicate some UI elements that we want to create form this word document. Click on right side of the screen from UI elements bar,
Each value should select via CONTROL + LEFT CLICK combination, when you add each value from Order Number, Your Full Name etc. will list from UI list from left side.
Now, we can rename it in order easily identified for each item value:
Extract data from window
You need to follow these steps to open extract data from window action from actions pane: UI Automation -> Data Extraction -> Extract data from window
Window: Select the variable that we created before,
Stored extracted data in: Change this field value as variable because we should rename it on Variables produced area, it provides easily understanding of each individual variable.As you can see, each variables are named meaningfully:
Get first free column/row from Excel worksheet
Now, we should added to the values that we got from previous steps, in order to do that select get first free column/row from Excel worksheet action:
Excel instance: When I launched the the excel file that we early created a variable called excel instance and this field refers back to that. Here we will get one variable with the first free column and another variable with the first free row.
Click on save
Write to Excel worksheet
I will select and drag it over as next step on the canvas:
Excel Instance: Previously created variable as konws as ExcelInstance appear automatically
Value to write: Each item should specified due to write these columns to excel file. In order to do that we select each individual item for each step
Column: Select a column which will first select from excel file. You can type manually value equals 1. Sequentially increase number of column value:
Row: Select variable as %FirstFreeRow% which is previously created from before
Terminate Process
Finally, we got the final step that terminate the process.
Click on System -> Terminate Process
Specify process by: Process ID
ProcessID: %AppProcessId %
Conclude
Now, we finished entering in all of the different steps of our flow and our automation. Before run the flow you can check the whole steps which are created due to move the data from different word files to sing excel sheet.
You can download the example Word files and Excel sheet over here
Thanks for reading.