Excel Character object through COM

Krisz krisztian.sinka at ericsson.com
Fri Aug 26 13:50:43 CEST 2005


Hi!

Maybe this question is already answared somewhere, but I could not find
it:

I want to modify one of the letters of a text of a Excel cell through
COM; let's say to make it red. The VB reference tells that it can be
managed with:

With Worksheets("Sheet1").Range("A1")
    .Value = "abcdefg"
    .Characters(3, 1).Font.Bold = True
End With

However when I try the similar in Python (I used the 'COM Makepy
utility' of Pythonwin) I got the following (Here 'A' is a class that
wraps the 'com' things):

>>> A.book.Worksheets(1).Range("a1").Characters
<win32com.gen_py.Microsoft Excel 9.0 Object Library.Characters instance
at 0x19420904>

>>> A.book.Worksheets(1).Range("a1").Characters(1,1)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
AttributeError: Characters instance has no __call__ method

So my question is that am I doing something wrong or there is a
different way to modify the color of a charater through COM.

Thank you.
Regards, Krisztian




More information about the Python-list mailing list