[Python.NET] Indexer not working on Interop

Phat Loc <[email protected]> Mon, 19 Mar 2018 16:50:31 -0400
Newsgroups gmane.comp.python.dotnet
Message-ID <CADG6+0N8co+4i5v60nA6sZs2m8u1WxvfnLOeKAdSU9Da0PjHaw@mail.gmail.com>
Hi All,

I was expecting the code below to work. Basically I casting a
System.__ComObject into a Range Interface (
https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range_members(v=office.14).aspx).
There should be an indexer but I can't seem to get it to work?

Thanks,

Phat


from PyExcel import PyAddin

import Microsoft.Office.Interop.Excel as Excel

app = Excel._Application(PyAddin.CurrentInstance.ExcelApp)

selection = Excel.Range(app.Selection)



In [5]: selection[1,1]

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-5-bb1b652c6740> in <module>()

----> 1 selection[1,1]



TypeError: 'Range' object is not subscriptable



In [6]: selection.Cells[1,1]

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-6-f8b14ac4d116> in <module>()

----> 1 selection.Cells[1,1]



TypeError: unindexable object



In [7]: selection.Cells(1,1)

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-7-e8b900b98026> in <module>()

----> 1 selection.Cells(1,1)



TypeError: object is not callable

_________________________________________________
Python.NET mailing list - [email protected]
https://mail.python.org/mailman/listinfo/pythondotnet