I have an Excel file with query tables in it. I want python to refresh and save it. Did some research and though I had found the perfect solution!
import win32com.client
# Start an instance of Excel
xlapp = win32com.client.DispatchEx("Excel.Application")
# Open the workbook in said instance of Excel
wb = xlapp.workbooks.open(r'C:\Users\User Name\Company\Management - Documents\Technical\Daily Data.xlsx')
# Optional, e.g. if you want to debug
xlapp.Visible = True
# Refresh all data connections.
wb.RefreshAll()
xlapp.CalculateUntilAsyncQueriesDone()
wb.Save()
# Quit
xlapp.Quit()
When I run this the code, it says the file is open in another application. I have office 365. What am I missing? I also tried the XlWings method and got an error!