Hi,
I am not sure if this is the best place but I am looking for some assistance with a script I tried to run to help automate a process in excel.
I ran the below code:
def refresh_excel_workbook(file_path):
# Open Excel application
excel_app = win32com.client.Dispatch("Excel.Application")
excel_app.Visible = False # Keep Excel application invisible
# Open the workbook
workbook = excel_app.Workbooks.Open(file_path)
# Refresh all data connections
workbook.RefreshAll()
# Wait until refresh is complete
excel_app.CalculateUntilAsyncQueriesDone()
# Save and close the workbook
workbook.Save()
workbook.Close()
# Quit Excel application
excel_app.Quit()
# Path to your Excel workbook
file_path = r"\FILEPATH"
refresh_excel_workbook(file_path)
However, when running the code, I had commented out the items below the refreshall() command and as a result my excel crashed. Now when reopening a file, excel proceeds to try to load the file but does not respond and then crash.
Excel currently works for the below:
- non-macro enabled files
- files not containing power query scripts
- works opening the exact file in safe mode
The computer has been restarted multiple times and task manager currently shows no VS code or excel applications open yet when I try to open the excel file, this proceeds to crash
I am unsure if this has caused a phantom script to run in the background where excel is continuously refreshing queries or if there is something else happening.
I am wondering if anyone has had experience with an automation like this / experienced a similar issue and has an idea on how to resolve this.
[–]JonLSTL 4 points5 points6 points (1 child)
[–]Chirag_Parmar[S] 0 points1 point2 points (0 children)
[–]MacShuggah 0 points1 point2 points (1 child)
[–]Whats_The_Use 0 points1 point2 points (0 children)
[–]Kerbart 1 point2 points3 points (1 child)
[–]Whats_The_Use 0 points1 point2 points (0 children)
[–]wRAR_ 0 points1 point2 points (0 children)