import win32com.client, os, shutil
xl = win32com.client.Dispatch("Excel.Application")
import pandas as pd
def convert_to_03xls(file,newfile):
file = os.path.abspath(file)
newfile = os.path.abspath(newfile)
# print('file', file)
# print('newfile', newfile)
xl.DisplayAlerts = False
wb = xl.Workbooks.Open(file)
# if os.path.exists(newfile):
# os.remove(newfile)
wb.SaveAs(newfile, FileFormat=56)
wb.Close()
xl.Quit()
xl.DisplayAlerts = True
Before saving the file set DisplayAlerts to False to suppress the warning dialog:
xl.DisplayAlerts = False
After the file is saved it is usually a good idea to set DisplayAlerts back to True:
xl.DisplayAlerts = True