Excel Character object through COM

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Krisz

    #1

    Excel Character object through COM

    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("She et1").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):
    [color=blue][color=green][color=darkred]
    >>> A.book.Workshee ts(1).Range("a1 ").Characte rs[/color][/color][/color]
    <win32com.gen_p y.Microsoft Excel 9.0 Object Library.Charact ers instance
    at 0x19420904>
    [color=blue][color=green][color=darkred]
    >>> A.book.Workshee ts(1).Range("a1 ").Characters(1 ,1)[/color][/color][/color]
    Traceback (most recent call last):
    File "<interacti ve 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

  • Max Erickson

    #2
    Re: Excel Character object through COM

    "Krisz" <krisztian.sink a@ericsson.com> wrote in
    news:1125057043 .800968.180180@ g47g2000cwa.goo glegroups.com:
    [color=blue][color=green][color=darkred]
    >>>> A.book.Workshee ts(1).Range("a1 ").Characters(1 ,1)[/color][/color]
    > Traceback (most recent call last):
    > File "<interacti ve 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.
    >[/color]

    try GetCharacters(1 ,1)

    max

    Comment

    • Krisz

      #3
      Re: Excel Character object through COM

      Thanks, it works...

      Krisz

      Comment

      Working...