|Top Previous Next|
Applies a number of transformations to a formula that aim to remove redundancy and complexity.
result1 = expression1.Optimize
expression1 Required. An expression that returns an IOAKAddIn object.
expression2 Required. An expression that returns an IOAKAPI object.
result1 An OAKResult enumeration indicating the success or otherwise of the action.
range1 Required Range. The range in which to which to apply the transformations,
mode Required OptimizationMode: One of OptimizationMode_Conservative, or OptimizationMode_None
When applied to an IOAKAddIn object, the Optimize method acts on the current selection to perform the same action as the OAK Development | Formula | Optimize command, including presentation of a dialog box to confirm the replacement of the untransformed formula by the transformed one.
When applied to an IOAKAPI object, the Optimize method acts on the cells indicated by Range1, and is told whether to apply optimization by the parameter mode. OAK5 no longer supports more than what was referred to as conservative optimization in OAK 4.
When applied to an IOAKAddIn object, the Optimize method follows the One-cell rule. When applied to an IOAKAPI object, it does not: if supplied a Range parameter describing a single cell, it will look in that cell only.
When applied to an IOAKAddIn object, the method will display a dialog box if no useful change can be made to any formula, just as the equivalent OAK user-interface command does.
It makes little sense to pass this method a mode of OptimizationMode_None. It won't do anything. The option is provided because the same parameter is also passed into the methods Reconstruct and Reformulate, where it is a legitimate choice.