"Baehr, Manuel" <manuel.ba...@comsoft.aero> wrote in message news:737a64deb003704788e5ce515ed146054b6...@csmail.comsoft.de...
Hi Mark,

I got an error with that as well, but I figured out the correct way:

import win32com.client
xl = win32com.client.gencache.EnsureDispatch('Excel.Application')
xl.Visible = True
xl.Workbooks.Add()
c = xl.ActiveCell
c.FormulaR1C1 = 'Hello World'
c.GetCharacters(1,5).Font.ColorIndex = 3
c.GetCharacters(7,5).Font.ColorIndex = 4

thanks for your answer, works like a charm!

I tried the macro-way as well but stopped because that didn't work.
How/where did you find out the correct way to use this feature
(GetCharacters instead of Characters)? This answer may prevent me from
asking further questions of this kind ;-)

Cheers,
Manuel

I couldn't find where it was documented, although I recalling reading about it years ago and had forgotten about it. In this case I was using PythonWin as the editor, and with the EnsureDispatch call popup tooltips are enabled. Typing "c." listed the "GetCharacters" and "SetCharacters" methods, but I didn't notice it immediately. Too bad the convention wasn't "CharactersGet" and "CharactersSet" or I would have found it quicker in the sorted tooltip list :^)

-Mark


_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to