Yes, you can implement a check for whether an Excel file is open before launching it in Power Automate. Here's a general approach you could use:
1. Use PowerShell or a Script in Power Automate:
- You can add a PowerShell script to check if an Excel file is open. If the file is open, PowerShell will return a specific value, which you can use in a conditional step.
- If the file is not open, the script will return a different value, triggering the launch step in your flow.
2. Example PowerShell Script:
- This script checks if a specific Excel file is open:
$filePath = "C:\Path\To\Your\ExcelFile.xlsx"
$excel = Get-Process | Where-Object { $_.ProcessName -eq "EXCEL" }
if ($excel -and (Get-Process | Where-Object { $_.Path -eq $filePath })) {
Write-Output "Open"
} else {
Write-Output "Closed"
}
- Save this script as a `.ps1` file and run it in your Power Automate flow. If it returns "Open," you can skip launching Excel.
3. Set Up Power Automate Condition:
- After running the PowerShell script, use the output to set up a condition in your flow:
- If the output is "Open," skip the "Launch Excel" action and proceed to the next step.
- If the output is "Closed," then launch Excel.
This approach will help you avoid crashes by confirming the file's status before launching it.