2

Excel の win32com バインディングについて質問があります。初期バインディングをセットアップし、O'Reilly の書籍「Win32 での Python プログラミング」のいくつかの例に従いました。

次のコードは正常に動作します。

book2.xlApp.Worksheets('Sheet1').Cells(1,1).Font.ColorIndex = 1
book2.xlApp.Worksheets('Sheet1').Cells(1,1).Font.ColorIndex = 2

数字に応じてセル全体の文字色を変更します。ただし、これは機能しません。

book2.xlApp.Worksheets('Sheet1').Cells(1,1).Characters(start,length).Font.ColorIndex = 1

次のコールバックを取得します。

Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AttributeError: Characters instance has no __call__ method

ただし、Excel VBA ではコードが機能します。誰でも私に解決策を教えてもらえますか? Excel セルの文字列の一部を変更する必要があります。

どうもありがとうございました。

4

1 に答える 1

6

GetCharacters を使用します。

Cells(1,1).GetCharacters(start,length).Font.ColorIndex = 1
于 2011-08-18T07:47:12.483 に答える