0

I am trying to refresh a macro enabled excel file through a python script. I have used win32com.client package for launching an excel instance and refreshing the file and trying to save it. I have also set DisplayAlerts = False. I am getting an alert like:

A file named 'F:\User\output\testfile.xlsm' already exists. Do you want to overwrite it?

I am not getting this alert for other xlsm files that I am trying to refresh even though there are files present with the same name in the destination folder. Here is a sample of the code I used to refresh the files:

import win32com.client as win32
xl = win32.DispatchEx('Excel.Application')
xl.DisplayAlerts = False
xl.Visible = False
xl.Interactive = False
xl.EnableEvents=False
wb = xl.Workbooks.Open(os.path.join(excel_path),ReadOnly=False, IgnoreReadOnlyRecommended =True)
xl.DeferAsyncQueries = True
wb.RefreshAll()
xl.CalculateUntilAsyncQueriesDone()
xl.DeferAsyncQueries = False
wb.SaveAs(output_filepath,ReadOnlyRecommended =False)
wb.Close(False)
xl.Quit()

Can anyone help me figure out why am I getting the alert only for that particular file? Thanks in advance.

Asish
  • 1

0 Answers0