[python-win32] Controlling Excel via COM: errors with conditionalformatting
Solomon.Zewdie.Altek at zf.com
Solomon.Zewdie.Altek at zf.com
Wed Sep 24 15:00:04 CEST 2008
How about this?:
channamesSheet.Cells(6, 3).Font.FontSize = 10
channamesSheet.Cells(6, 3).Font.ColorIndex = "blue"
channamesSheet.Cells(6, 3).Value = "something..."
channamesSheet.Cells(6, 3).Font.Name = "Arial"
...
I am not 100% sure whether it works, but i would try that!
Regards,
Solomon Z.
Von: python-win32-bounces+solomon.zewdie.altek=zf.com at python.org im Auftrag von kurt munson
Gesendet: Mi 24.09.2008 14:47
An: python-win32 at python.org
Betreff: [python-win32] Controlling Excel via COM: errors with conditionalformatting
I have written a Python program to control MS Excel via win32com.client. This allows me to create and control an Excel spreadsheet.
I want to use Excel's conditional formatting to color certain cells, but I can't get it to work.
Here's the code I use:
import win32com.client
xl= win32com.client.Dispatch("Excel.Application")
....
....
....
channamesSheet.Cells(6,3).FormatConditions.Add() Type:=1, Operator:=4, Formula1:="=C5"
channamesSheet.Cells(6,3).FormatConditions(1).Interior.ColorIndex = 3
I got this code from a record and replay macro in Excel, then swapped out the xl constants for numeric values (1 and 4).
This gives me a syntax error when running.
I have tried both .Add and .Add(), since sometimes these () are necessary.
What am I doing wrong?
________________________________
Get more out of the Web. Learn 10 hidden secrets of Windows Live. Learn Now <http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_getmore_092008>
More information about the python-win32
mailing list