I have an Excel file that I run a Python script on. The Excel file has external data connections that need to be refreshed before the Python script is run. The functionality
CalculateUntilAsyncQueriesDone() will hold the program and wait until the refresh has completed.
xlapp = win32com.client.DispatchEx("Excel.Application") wb = xlapp.Workbooks.Open() wb.RefreshAll() xlapp.CalculateUntilAsyncQueriesDone() wb.Save() xlapp.Quit()