Hi, I am trying to access the cells in Excel by using its index. VBA docs point to the "Cells" property of "Range" or "Worksheet" object. This property accepts (rowIndex, colIndex) parameters & returns a 'Range' object containing the cell. However, in the module generated by comtypes 0.4.1 for Excel 2000 contains following snippet in the definition of IRange:
_00020813_0000_0000_C000_000000000046_0_1_4.py Line 51198: COMMETHOD(['propget'], HRESULT, 'Cells', ( ['retval', 'out'], POINTER(POINTER(Range)), 'RHS' )), _00020813_0000_0000_C000_000000000046_0_1_4.py Line 51281: COMMETHOD(['nonbrowsable', 'propget'], HRESULT, '_Default', ( ['in', 'optional'], VARIANT, 'RowIndex' ), ( ['in', 'optional'], VARIANT, 'ColumnIndex' ), ( ['in', 'lcid'], c_int, 'lcid', _lcid ), ( ['retval', 'out'], POINTER(VARIANT), 'RHS' )), COMMETHOD(['nonbrowsable', 'propput'], HRESULT, '_Default', ( ['in', 'optional'], VARIANT, 'RowIndex' ), ( ['in', 'optional'], VARIANT, 'ColumnIndex' ), ( ['in', 'lcid'], c_int, 'lcid', _lcid ), ( ['in'], VARIANT, 'RHS' )), The result is that there is a property named _Default which behaves like the Cells property. I have a contrived example below: >>> import comtypes.client >>> xla = comtypes.client.CreateObject('Excel.Application') >>> from comtypes.gen import Excel >>> wb = xla.Workbooks.Add() >>> r = wb.ActiveSheet.Range('A1:A5') >>> r.Cells(1, 1) Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> r.Cells(1, 1) TypeError: 'POINTER(Range)' object is not callable >>> r.Cells <POINTER(Range) ptr=0x284964 at 1287850> >>> r._Default(1, 1) <POINTER(Range) ptr=0x28cec4 at 1287990> >>> Is this a bug in comtypes code generator? Or is this a limitation of COM itself and I can safely use _Default instead of Cells? Thanks & Regards, Suraj ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users