Forum Discussion

Dewi_Tjia's avatar
Dewi_Tjia
Copper Contributor
Apr 01, 2022

Fail to refresh excel file using python scripts

Hi Team,

 

I have a routine task to refresh some excel files (that are connected to several queries) in my local computer drive using python scripts as follows

 

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("C:/Excel_file.xlsx")

# Optional
xlapp.Visible = True

# Refresh all data connections.
wb.RefreshAll()
xlapp.CalculateUntilAsyncQueriesDone()
wb.Save()
wb.Close(True) # close just the workbook leaving the program open

# Quit
xlapp.Quit()

 

However, at the end of the process, the excel provides the following message. 

Despite of this. The files are actually saved/updated to the date when the refreshing process is performed.  I am using  Microsoft office 365 with 64 bits. 

 

Any helps are much appreciated. Thank you.

 

Regards,

Dewi

No RepliesBe the first to reply

Resources