Power Automate Desktop - Excel Automation Explanation
📄 Power Automate Desktop - Excel Automation Explanation
This PAD flow allows the user to select an Excel file, extract all table values automatically, and display them in a popup message. Below is the detailed step-by-step process:
1️⃣ Select Excel File
A file dialog appears prompting the user to select an Excel file (*.xls*). If the user
clicks Cancel, the flow stops.
2️⃣ Launch Excel
The flow launches the selected Excel file in visible and editable mode. Error handling ensures the file opens correctly.
3️⃣ Detect Data Range
PAD automatically determines the first free row and first free column in the Excel sheet. This allows the flow to dynamically calculate the exact data range.
4️⃣ Read Data
Using the detected boundaries, PAD reads the entire data table starting from column A row 1, up to the last used row and column. The extracted table is stored in the variable ExcelData.
5️⃣ Close Excel
After reading, the Excel document is closed to prevent locking issues.
6️⃣ Show Extracted Data
Finally, a message dialog displays the extracted table values to the user.
💡 Final PAD Code Used
# The following action prompts you to select an Excel file (*.xls*) that contains the table you want to extract.
Display.SelectFileDialog.SelectFile Title: $'''Select the excel file to extract table from...''' FileFilter: $'''*.xls*''' IsTopMost: True CheckIfFileExists: True SelectedFile=> SelectedFile ButtonPressed=> ButtonPressed
IF ButtonPressed <> $'''Cancel''' THEN
Excel.LaunchExcel.LaunchAndOpen Path: SelectedFile Visible: True ReadOnly: False LoadAddInsAndMacros: False Instance=> ExcelInstance
ON ERROR REPEAT 1 TIMES WAIT 2
END
Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: FirstFreeColumn - 1 EndRow: FirstFreeRow - 1 FirstLineIsHeader: False GetCellContentsMode: Excel.GetCellContentsMode.PlainText RangeValue=> ExcelData
Excel.CloseExcel.Close Instance: ExcelInstance
Display.ShowMessageDialog.ShowMessage Title: $'''Excel table values extracted:''' Message: ExcelData Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed1
END
Comments
Post a Comment