Newbie: Win32 COM problem

Discussion in 'Python' started by Paul Hemans, Aug 25, 2010.

  1. Paul Hemans

    Paul Hemans Guest

    Simple class to wrap the xlwt module for COM access

    from xlwt import Workbook

    class WrapXLS:
    _reg_clsid_ = "{c94df6f0-b001-11df-8d63-00e09103a9a0}"
    _reg_desc_ = "XLwt wrapper"
    _reg_progid_ = "PyXLS.Write"
    _public_methods_ =
    # _public_attrs_ = ['book']

    def __init__(self): = None

    def createBook(self): = Workbook()

    def createSheet(self,sheetName):

    def writeSheetCell(self, sheet, row, col, value, style=""):
    sheet =

    def saveBook(self,fileName):

    if __name__=='__main__':
    import win32com.server.register

    It registers ok with --debug. Code executing within Foxpro (no comments
    oPyXLS.createSheet("Sheet 1") -- Error here

    Output in Python Trace Collector (PythonWin):
    in _GetIDsOfNames_ with '(u'createsheet',)' and '1033'

    in _Invoke_ with 1001 1033 3 (u'Sheet 1',)
    Traceback (most recent call last):
    File "C:\Python26\lib\site-packages\win32com\server\", line
    47, in _Invoke_
    return self.policy._Invoke_(dispid, lcid, wFlags, args)
    File "C:\Python26\lib\site-packages\win32com\server\", line 277,
    in _Invoke_
    return self._invoke_(dispid, lcid, wFlags, args)
    File "C:\Python26\lib\site-packages\win32com\server\", line 282,
    in _invoke_
    return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None)
    File "C:\Python26\lib\site-packages\win32com\server\", line 585,
    in _invokeex_
    return func(*args)
    File "C:\development\PyXLS\", line 13, in createSheet
    def createBook(self):
    AttributeError: WrapXLS instance has no attribute '_book'
    pythoncom error: Python error invoking COM method.

    Can anyone help?
    Paul Hemans, Aug 25, 2010
    1. Advertisements

  2. Paul Hemans

    Mark Hammond Guest

    That line seems an unlikely source of the error. Note that as win32com
    uses an in-process model by default, your problem may be that you
    changed your implementation but didn't restart the hosting process - and
    therefore are still using an earlier implementation.


    Mark Hammond, Aug 26, 2010
    1. Advertisements

  3. Paul Hemans

    Paul Hemans Guest

    Yes, that was it. I just needed to restart the host process.
    Paul Hemans, Aug 26, 2010
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.