Discussion:
[python-win32] Win32com Error any suggestions?
Carl Evans
2015-04-15 17:56:56 UTC
Permalink
Hi,

I am trying to dipatch excel using the win32com library but for some reason
am running into an issue. I have the following code:


import win32com.clientimport os

file1= r'C:\\Users\cevans\Desktop\models1\file.xlsm'
def refresher():
if os.path.exists(file1):
xl = win32com.client.Dispatch("Excel.Application")
xl.Workbooks.Open(Filename=file1,ReadOnly=1)
xl.Visible = True
xl.Application.Run('Report_Tablerefresh1')
xl.Workbooks(1).Close(SaveChanges=1)
xl.Application.Quit()
del xl
refresher()



Which causes this error:

Traceback (most recent call last):
File "C:/Users/cevans/PycharmProjects/RigLocatorMapPull/Pipe_StorageRefresh.py",
line 17, in <module>
refresher()
File "C:/Users/cevans/PycharmProjects/RigLocatorMapPull/Pipe_StorageRefresh.py",
l ine 10, in refresher
xl = win32com.client.Dispatch("Excel.Application")
File "C:\Python27\lib\site-packages\win32com\client\__init__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py",
line 104, in _GetGoodDispatchAndUserNamereturn
(_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py",
line 84, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
pywintypes.com_error: (-2146959355, 'Server execution failed', None, None)



I have tried several things to no avail, any suggestions?
--
Carl E. Evans MSc.
Tim Roberts
2015-04-16 17:02:40 UTC
Permalink
Post by Carl Evans
I am trying to dipatch excel using the win32com library but for some
The obvious question is, do you have Excel installed?

That error (80080005) means that the COM server app (Excel, in this
case) did not start up and register itself within the timeout period,
which is usually a very long time -- 2 minutes. If you start Excel by
hand, does it start right up? Is it possible you ran this on a machine
that had a trial version, and the trial period had expired, or the app
had never been run and its trying to install itself?
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Tim Roberts
2015-04-16 18:46:01 UTC
Permalink
I can open excel fine with no issues. Its a full 64bit edition, so no
trial or anything. Also, when I run the script, this error occurs in
about 2 seconds, so not waiting for any sort of time out.
Very odd. Has this EVER worked for you? You aren't trying to run this
from a scheduled task or a service, are you?
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Tim Roberts
2015-04-16 20:37:22 UTC
Permalink
This post might be inappropriate. Click to display it.
mc@mclaveau
2015-04-17 06:08:12 UTC
Permalink
Hi!
I am running 32bit Python 2.7 on 64bit excel
Warning! 64 bits Excel have not the same CLSID than 32 bits Excel.
If it run in tests/dev. with 32 bits Excel, try to install a 32 bits
Office on the production computer.
MS himself advises to prefer the 32-bit version.

@-salutations
--

Loading...