I am having problems setting up Conditional Formatting from Delphi XE2 using Early binding with Excel 2010
The Macro I am 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 as I might I cannot seem to access the equivalent of Selction.FormatConditions(1)
to work
The closest I have reached is with the following code:
XR := Xlapp.Range(...)
XR.FormatConditions.Delete;
XR.FormatConditions.Add(xlCellValue, xlGreater, '=6', EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
Which works. When I try and define the colours I have problems
FC := XR.FormatConditions[1];
FC.SetFirstPriority;
with FC.Interior do
begin
PatternColorIndex := xlAutomatic;
ThemeColor := xlThemeColorAccent6;
end;
However this keeps telling me that XR.FormatConditions(1) is and IDispatch and thus incompatible with the FormatCondition assignment
What am I doing wrong?