SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
piterdias
Topic Author
Posts: 59
Joined: July 14th, 2002, 3:00 am

How to disable Excel function wizard evaluating function?

July 13th, 2011, 7:32 pm

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,
 
User avatar
kimosabe
Posts: 416
Joined: November 25th, 2003, 12:24 pm

How to disable Excel function wizard evaluating function?

July 13th, 2011, 8:06 pm

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.
 
User avatar
Govert
Posts: 103
Joined: January 28th, 2006, 10:02 am

How to disable Excel function wizard evaluating function?

July 14th, 2011, 2:22 pm

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
Last edited by Govert on July 13th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
piterdias
Topic Author
Posts: 59
Joined: July 14th, 2002, 3:00 am

How to disable Excel function wizard evaluating function?

July 15th, 2011, 5:07 pm

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.
 
User avatar
FastExcel
Posts: 50
Joined: December 2nd, 2003, 8:10 am

How to disable Excel function wizard evaluating function?

July 25th, 2011, 9:28 am

In VBA you can use this method to exit the function:If (Not Application.CommandBars("Standard").Controls(1).Enabled) Then Exit Function
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On