I'm having trouble setting up conditional formatting from Delphi XE2 using early binding with Excel 2010
The macro I'm trying to reproduce is as follows:
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _ Formula1:="=6" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0 End With Selection.FormatConditions(1).StopIfTrue = False
Try so that I can not access the Selction.FormatConditions(1) equivalent to work
The closest I came to has the following code:
XR := Xlapp.Range(...) XR.FormatConditions.Delete; XR.FormatConditions.Add(xlCellValue, xlGreater, '=6', EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
What works. When I try to identify colors I have problems
FC := XR.FormatConditions[1]; FC.SetFirstPriority; with FC.Interior do begin PatternColorIndex := xlAutomatic; ThemeColor := xlThemeColorAccent6; end;
However, this continues to tell me that XR.FormatConditions (1) is also an IDispatch, and therefore incompatible with the purpose of FormatCondition
What am I doing wrong?
source share