Excel = actxserver('Excel.Application');
set(Excel,'Visible',0);
Workbook = invoke(Excel.Workbooks, 'open', [fpath filesep file ext]);
sheet = get(Excel.Worksheets, 'Item',sheetname);
invoke(sheet,'Activate');
ExAct = Excel.Activesheet;
ExActRange = get(ExAct,'Range',range);
ExActRange.Select;
xlExpression=1;
Excel.Selection.FormatConditions.Delete;
Excel.Selection.FormatConditions.Add(xlExpression, [>], ['-1000']);
Excel.Selection.FormatConditions.Item(1).Font.ColorIndex = 56;
This program gives me following error:
??? Invoke Error, Dispatch Exception: Parameter not optional.
you have to provide the operator corresponding value, as explained below:
xlCellValue = 1
Excel.Selection.FormatConditions.Add(xlCellValue,Operator,Formula1,Formula2);
Operator:
1 = xlBetween
2 = xlNotBetween
3 = xlEqual
4 = xlNotEqual
5 = xlGreater
6 = xlLess
7 = xlGreaterEqual
8 = xlLessEqual
Formula 2 is only supported when "xlBetween" or "xlNotBetween" is used.
example:
Excel.Selection.FormatConditions.Add(xlCellValue,1,'-2','5'); % format when the value is between -2 & 5
Excel.Selection.FormatConditions.Add(xlCellValue,2,'-2','5'); % format when the value is NOT between -2 & 5
Excel.Selection.FormatConditions.Add(xlCellValue,3,'10'); % format when the value is equal 10
I know its a late reply, but it could help others who could search for the same issue.
Best Regards,
"Prashant " <prasru...@yahoo.com> wrote in message <hlc1cj$9ro$1...@fred.mathworks.com>...