I use this function to access Excel and update the spreadsheet data, but now in the afternoon it doesn't want to work. The function runs smoothly on my Windows 10, but on Windows Server 2012 it presents this problem. Here's the code:
from win32com import client as win
def atualizar_planilha(file=''):
try:
excel = win.Dispatch('Excel.Application')
excel.Visible = False
planilha = excel.Workbooks.open(file)
planilha.RefreshAll()
excel.CalculateUntilAsyncQueriesDone()
planilha.Save()
planilha.Close(SaveChanges=True)
excel.Quit()
return True
except Exception as e:
print(e)
return False
all the previous code, the Dispatch() function is executed, but when it reaches it, it ends up resulting in this problem.
Someone to help me?
I already uninstalled and installed python and it didn't solve the problem.