0

The code works fine, the only issue is the excel.Visible = False works fine on my colleague's laptops but doesnt on mine. Also I think there is same issue with excel.DisplayAlerts = False.

any reason why this is happening?

below are my codes

import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
excel.Visible = False  # Set Excel to be hidden
excel.DisplayAlerts = False
wb = excel.Workbooks.Open(filename)
ws = wb.Sheets('tab_name')
ws.Range('K3').Value = 0.55
ws.Range('K4').Value = 1
ws.Range('K7').Value = 0

ws.Range('K8').Value = 1
ws.Calculate()
wb.Save()
wb.Close()
excel.Quit()
TRex
  • 445
  • 5
  • 14
  • Are them the same version of Excel and Windows? Do both versions have enabled using Macros by default? Are any other security measures on one computer that is not on the other one? – vicenteherrera May 25 '23 at 10:23
  • Check this other question, see if setting `excel.Interactive = False` before changing visibility solves your problem. https://stackoverflow.com/questions/54815848/python-win32com-visible-false-not-working – vicenteherrera May 25 '23 at 10:27
  • thanks both the solutions in other link didnt work, also am not sure how different our versions are. will have to check with the IT team – TRex May 25 '23 at 10:47

0 Answers0