Dispatch("Excel.Application") failed

Discussion in 'Python' started by lialie, Mar 13, 2008.

  1. lialie

    lialie Guest

    Hi,
    Maybe it 's quite simple, but I can't fix it. Do I make some mistakes in
    my env setting? My excel version is 2003.
    any suggestion? Thanks.

    Traceback (most recent call last):
    File "testexcel.py", line 3, in ?
    excel = Dispatch("Excel.Application")
    File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line
    95, in
    Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
    lsctx)
    File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
    98, in _
    GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
    File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
    78, in _
    GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
    D_IDispatch)
    pywintypes.com_error: (-2147221005,
    '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xb1\xf0\xd7\xd6\xb7\xfb\xb4\xae',
    None, None)
    lialie, Mar 13, 2008
    #1
    1. Advertising

  2. On Mar 13, 1:02 am, lialie <> wrote:
    > Hi,
    > Maybe it 's quite simple, but I can't fix it. Do I make some mistakes in
    > my env setting? My excel version is 2003.
    > any suggestion? Thanks.
    >
    > Traceback (most recent call last):
    > File "testexcel.py", line 3, in ?
    > excel = Dispatch("Excel.Application")
    > File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line
    > 95, in
    > Dispatch
    > dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
    > lsctx)
    > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
    > 98, in _
    > GetGoodDispatchAndUserName
    > return (_GetGoodDispatch(IDispatch, clsctx), userName)
    > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
    > 78, in _
    > GetGoodDispatch
    > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
    > D_IDispatch)
    > pywintypes.com_error: (-2147221005,
    > '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xb1\xf0\xd7\xd6\xb7\xfb\xb4\xae',
    > None, None)


    I'm not seeing anything obviously wrong. What version of Windows are
    you using? Are you logged in as an admin?

    You also might try the PyWin32 user's mailing list:
    http://mail.python.org/mailman/listinfo/python-win32

    Mike
    Mike Driscoll, Mar 13, 2008
    #2
    1. Advertising

  3. lialie

    John Machin Guest

    On Mar 13, 5:02 pm, lialie <> wrote:
    > Hi,
    > Maybe it 's quite simple, but I can't fix it. Do I make some mistakes in
    > my env setting? My excel version is 2003.
    > any suggestion? Thanks.
    >
    > Traceback (most recent call last):
    > File "testexcel.py", line 3, in ?
    > excel = Dispatch("Excel.Application")

    [snip]
    > pywintypes.com_error: (-2147221005,
    > '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xb1\xf0\xd7\xd6\xb7\xfb\xb4\xae',
    > None, None)


    Googling for 2147221005 gives some clues.

    That string of hex stuff appears where an error message is expected --
    it's not utf8, and makes no sense when I attempt to decode it with
    cp1250 to cp1258 inclusive. If you start IDLE and type:

    import sys; sys.stdout.encoding

    what do you see?
    John Machin, Mar 13, 2008
    #3
  4. > On Behalf Of John Machin
    > > '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xb1\xf0\xd7\xd6\xb7\xfb\xb4\xae',
    > > None, None)

    >
    > Googling for 2147221005 gives some clues.
    >
    > That string of hex stuff appears where an error message is
    > expected -- it's not utf8, and makes no sense when I attempt
    > to decode it with cp1250 to cp1258 inclusive. If you start
    > IDLE and type:


    The hex stuff is Chinese. It appears to be a standard Windows error message.
    ÎÞЧµÄÀà±ð×Ö·û´® (Which I believe meaans "invalid class string")

    I wrote in another post (that doesn't appear to have made it to the list)
    that the call to Dispatch on Excel will fail if the formula bar edit box is
    active. Just another idea.

    Regards,
    Ryan Ginstrom
    Ryan Ginstrom, Mar 13, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sck10
    Replies:
    6
    Views:
    909
    sck10
    Sep 1, 2006
  2. lialie
    Replies:
    0
    Views:
    356
    lialie
    Mar 14, 2008
  3. kiran
    Replies:
    5
    Views:
    3,395
  4. Cupric
    Replies:
    1
    Views:
    405
    Larry Bates
    Nov 9, 2008
  5. Replies:
    1
    Views:
    187
    Jan Svitok
    Aug 2, 2006
Loading...

Share This Page