Suraj Barkale schrieb:
> 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.

When in VB you call the "Cells" property with (rowIndex, colIndex)
parameters, behind the scenes VB retrieves the "default" property,
with DISPID_VALUE == 0, from the 'Range interface' that the "Cells"
property is.  Looking into the generated module, the "default" property
with DISPID_VALUE is named '_Default'.

In comtypes, there is currently no such magic.  You have to do this:

  xxx.Cells._Default(1, 1)

It would probably be a good idea to change the "magic" that comtypes
currently implements into something that is more compatible with VB
(or other scripting languages).
The current comtypes "magic" is this:

  If an interface has a property named "Item" then the interface
  gets a .__call__(self, *args, **kw) method that will call
  self.Item(*args, **kw).  Additionally, a __getitem__(self, index)
  method is added that will also call self.Item(index).  This behaviour
  is independend from the dispid that the "Item" property has.


IIRC, win32com does this:

  Calling an interface will call the DISPID_VALUE property (if the
  interface has one).  This does not depend on the name that the
  property has.

  Indexing an interface will call .Item(index).

However, I fear that changing this may break some existing programs.

Thomas


-------------------------------------------------------------------------
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://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to