To automate the refreshing of Power Query in Excel using Power Automate, you can utilize the "Run script" action effectively. However, there are a few considerations to ensure it works smoothly:
- Ensure the Script is Correct: Make sure that the Office Script you created for refreshing the Power Query table is functioning correctly when run manually. If it works manually but not through Power Automate, there may be issues with how the script is set up or how Power Automate is configured to call it.
- File Access Issues: The error message indicating that the file is open by another user suggests that the Excel file might be locked. Ensure that no other instances of the file are open when you attempt to run the script through Power Automate. You may need to close all instances or ensure that the file is not being accessed by another process.
- Using Power Automate: In Power Automate, after setting up the flow to run the script, you can add additional actions to save a copy of the master file. Make sure to use the appropriate connectors (like OneDrive or SharePoint) to handle file operations.
- Testing the Flow: Test the flow step by step to identify where it might be failing. You can add logging or notifications in your flow to help diagnose issues.
- Licensing: Ensure that you have the necessary licensing for using Power Automate with Office Scripts, as some features may be restricted based on your subscription.
If you continue to face issues, reviewing the specific error messages in Power Automate can provide more insight into what might be going wrong.
References: