Page 1 of 1

How to disable Excel function wizard evaluating function?

Posted: July 13th, 2011, 7:32 pm
by piterdias
Guys,We are using ExcelDNA in order to implement some functions in C# but don?t want them to be evaluated in Excel Function Wizard.There should be a function that tells if the function is running inside Function Wizard but I don?t know which.Could you someone help?Regards,

How to disable Excel function wizard evaluating function?

Posted: July 13th, 2011, 8:06 pm
by kimosabe
Here's how to do it in C++: http://msdn.microsoft.com/en-us/library ... #Y241Click on the C++ tab to see the code. Excel-DNA can call C++ code, but I would be interested in a pure C# solution too.

How to disable Excel function wizard evaluating function?

Posted: July 14th, 2011, 2:22 pm
by Govert
Hi Piter,In Excel-DNA you call ExcelDnaUtil.IsInFunctionWizard().It implements the method that Keith pointed to.Be aware that this call can be quite slow (maybe 0.4 ms), so you should only check for functions that would be fairly slow to evaluate anyway (this is the common use case - you want to avoid recalculating on every change the user makes in the wizard). For fast functions you are better off adding more careful parameter validation, and allowing them to calculate in the function wizard safely.There was some discussion on the performance, and alternatives, here: http://groups.google.com/group/exceldna ... b11f.Other ways of checking seemed slower than the current check. The issue is that it takes an enumeration through all the Excel process windows to check, and this just takes a bit of time.The C# implementation in version 0.29 of Excel-DNA (in ExcelDna.Integration\Excel.cs) is pasted below.Regards,GovertExcel-DNA - Free and easy .NET for Excel

How to disable Excel function wizard evaluating function?

Posted: July 15th, 2011, 5:07 pm
by piterdias
Govert,That is the winner!We thought about implementing the MSDN code pointed by kimosabe or the one implement in functioncall.cpp of ObjectHandler (from QuantLib project, pretty the same), but it is much better keeping everything from the same library.Thanks a lot everyone.

How to disable Excel function wizard evaluating function?

Posted: July 25th, 2011, 9:28 am
by FastExcel
In VBA you can use this method to exit the function:If (Not Application.CommandBars("Standard").Controls(1).Enabled) Then Exit Function