Whenever I execute
xl = win32com.client.DispatchEx("Excel.Application")
xl.Visible = True
together, I get an error. But the error doesn't appear if I execute line by line
xl = win32com.client.DispatchEx("Excel.Application")
then
xl.Visible = True
Error:
xl = win32com.client.DispatchEx("Excel.Application")
xl.Visible = True
Traceback (most recent call last):
File "<ipython-input-10-ea9dc88dd3f0>", line 2, in <module>
xl.Visible = True
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 565, in __setattr__
self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value)
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2146777998), None)
Does anyone know how to fix this problem?