IBuiltInFunctions.ExecuteCustomFunction (String, IRange, IRange) Method
Parameters
- functionName
- string
The name of the function to be executed. Case insensitive.
- sourceRange
- IRange
The source range with the data passed to the function. Read only (values are string or double). Usually, this range belongs to some overhead sheet.
- targetRange
- IRange
The target range to which the data returned from the function will be written (values are string or double). This can be in a different workbook that the sourceRange. Usually, this range belongs to some overhead sheet.
Return Value
stringThe result of the function call. An empty string if no problem was encountered. The "[CANCELED]", if the action was canceled by the user, in which case no message was displayed. Otherwise the error message, which was also displayed to the user. The method doesn't throw any exceptions, all errors are reported with the return value.
The following example will call the custom function "My_Custom_Function_1" on the "Sample Function" sheet in the overhead.
// Execute the function on the "Sample Function" sheet in the overhead. try { // Get the overhead workbook. The lock is required. es.CurrentVersion.Overhead.GetLockOnWorkbook(); var wbook = es.CurrentVersion.Overhead.GetWorkbook(); // Get the "Sample Function" sheet. var wsheet = wbook.Worksheets["Sample Function"]; // Get the ranges. var sourceRange = wsheet.Range["N8:P10"]; var targetRange = wsheet.Range["S8:U10"]; // Call the custom function which will write the data to the target range. es.BuiltInFunctions.ExecuteCustomFunction("My_Custom_Function_1", sourceRange, targetRange); } finally { // Release the lock on the overhead workbook in any case. es.CurrentVersion.Overhead.ReleaseLockOnWorkbook(); }
This language is not supported or no code example is available.