104

This question has been asked before, but each time the accepted answer is simply a resignation to provide function descriptions using Application.MacroOptions (VBA6) (VBA7), but this information does not actually appear as a tooltip, so it does not solve my problem.

The Goal

What we all desire is to be able to define custom functions by any means (VBA, VSTO, or COM add-in) and give the user the benefit of a pop-up/tool-tip description of the function and its parameters, as appears for every built-in Excel function, either inline or in the formula bar:

enter image description here

enter image description here

The widely accepted answer to this need is that it is not possible for custom functions, but I wish to challenge that belief.

The Problem

Currently, the best I've seen anyone do is to define functions (often using the above MacroOptions call) so that when bringing up the function dialog (the fx button in the formula bar) their function and parameter descriptions appear as below:

enter image description here

As you can see, this is a complicated function with many parameters. If the user is not aware of this "function arguments" dialogue and how to bring it up, and are instead familiar only with Excel's standard tooltip, they will only see the formula name and no additional help:

enter image description here

With which they have no chance of correctly providing the required parameters. (Without reading the documentation, which of course, no user ever does.)

Now, a power user might know that by typing Ctrl+Shift+A, they will be granted a auto-completed list of function parameters like so:

enter image description here

But of course, we have the same problem as above which is that standard excel users will only be used to the default behavior from the first image and will probably never have learned that feature.

It should be clear by this point why this isn't enough and we want what every built in function has - the in-line tool-tip that tells the user how to use the function.

The Tease

At first, I might have been convinced that this simply isn't possible except with the native Excel application functions. Add-ins and VBA are extensibility features, and this tool-tip may simply not be extensible. But that theory is challenged by the existence of the Analysis Toolpak add-in. Sure, it's built in Microsoft, but ANALYS32.xll is a standalone XLL add-in just like those that can be produced in VB, C, C++, and C#. Sure enough, when this XLL is loaded into the application the functions that it makes available have the same tool-tips of native excel functions:

enter image description here

Surely if this information is somehow encoded in this XLL file and passed on to Excel, there is a way to replicate it with our own Add-ins? I'm at the point now where I'm going to start teaching myself a little about decompiling and seeing if I can reverse-engineer whatever is going on in the analysis toolpak.

How You Can Help

I'm almost certain that I've researched all the publicly available information there is about this problem. If someone knows something I don't know that might help with this though, feel free to chime in. I am very unfamiliar with reverse-engineering compiled dlls / xlls, so if someone feels like popping open their local copy of Analysis32.xll and figuring out what's going on with it's custom function definitions, I would be much obliged. Otherwise, I'll just keep digging into this myself until I've hit all the dead ends and report back what I find.

Community
  • 1
  • 1
Alain
  • 24,704
  • 19
  • 103
  • 170
  • 4
    **It is not possible to create or show tooltips for UDF arguments in current Excel versions using any of the available technologies.** Source by MVP: http://answers.microsoft.com/en-us/office/forum/office_2007-customize/how-to-show-udf-arguments-in-the-sheet/96750383-8872-e011-8dfc-68b599b31bf5?msgId=be37ec28-8d72-e011-8dfc-68b599b31bf5&tab=AllReplies#tabs – silkfire Jun 03 '13 at 19:56
  • .NET Reflector couldn't open ANALYS32.xll, concluding that it isn't a .NET Assembly. This surprises me. Looks like I'm going to have to try to decompile it to assembly language? – Alain Jun 03 '13 at 20:45
  • 5
    Sounds interesting, but I have in the past (office 97) made tooltips that using the winapi. And in that way you can do it. If thats interesting I can dig up the info and try to make an anwer out of it. – Archlight Jun 04 '13 at 13:52
  • @Archlight that's the spirit! My next strategy if this dead-ends is to try and generate some custom toop-tip or hints elsewhere in the UI but the complexities of monitoring user activity to figure out the correct time to display it seems frightening. I'd love to see what you put together. – Alain Jun 04 '13 at 17:59
  • I would really love to see this. I have gotten to the point where I have completely given up with custom Excel functions just because of the lack of this vital feature. Suppose the user just wants to type in a UDF but it has 10 parameters and they do not want to use the function screen it really is ridiculous. – CodeCamper Jun 05 '13 at 01:30
  • 1
    I will get it too you, it will take some time digging this up. But it should get up here for others to use. Its low down and evil combo of winapi/vba/ and I think I made it as vb.dll but its no prob lifting it up to .net – Archlight Jun 05 '13 at 06:27
  • Sounds like some `Attribute` you should add to the methods you use to make those functions. Can you search out for all `Attributes` provided by the Excel Interop Library?? – Daniel Möller Jun 05 '13 at 13:58
  • Just One Question before i try to take up the Challange. on which Excel Version should this work? < 98, 2k+, 2k2+, 2k7+, ... I'am not sure if it makes a big difference, but i it better to know the target System. – winner_joiner Jul 03 '13 at 06:16
  • @winner_joiner I'd aim for 2007, as it appears to be the most in use at the moment, but 2003 may be simpler because it only has an x86 version. 2010 and 2013 are most modern, but I doubt any additional functionality exists in their APIs that facilitate this. Probably won't make a big difference, as they all appear to use the same version of the analysis toolpak. – Alain Jul 03 '13 at 16:19
  • I suggest to cross post in http://reverseengineering.stackexchange.com – sw. Jul 06 '13 at 20:19
  • As mentioned in one of the answers below, the BINOMDIST function is a red herring. It's not actually part of the Analysis ToolPak add-in. Also, the functions that used to be in the Analysis ToolPak are now (since Excel 2007) fully integrated as native functions in Excel, and show those pretty tooltips. – Govert Jul 11 '13 at 11:27
  • @Govert I replaced Binomdist screenshot with TBillPrice, something from the analysis toolpak. I removed the Analysis ToolPak addon from my 2007 excel instance and noticed that you're correct, the functions are there regardless. How odd. I'll have to find a 2003 instance to confirm that the tooltips do not appear for the analysis toolpak in earlier versions. If so, I apologize for the huge false premise in my question. It also makes your answer all the more impressive and most likely to end up as the permanent go-to solution once ironed out. – Alain Jul 11 '13 at 12:42
  • 1
    Apparently the Excel development team is taking votes for this feature here: https://excel.uservoice.com/forums/304921-excel-for-windows-desktop-application/suggestions/10198185-intellisense-for-user-defined-functions – Alain Nov 15 '18 at 17:39

3 Answers3

42

I've posted a proof-of-concept project to GitHub as the Excel-DNA IntelliSense project, implementing this.

Using the UI Automation classes to monitor the appropriate Excel user interface events, a form is displayed when appropriate.

The code is wrapped as an Excel-DNA add-in, and works on my Excel 2013 / Windows 8 machine. I've tested on one other configuration (64-bit Excel 2010 on Windows Server 2008) and had a serious problems.

For a C# function defined with the Excel-DNA attributes like this:

[ExcelFunction(Description = 
    "A useful test function that adds two numbers, and returns the sum.")]
public static double AddThem(
    [ExcelArgument(Name = "Augend", 
                   Description = "is the first number, to which will be added")] 
    double v1,
    [ExcelArgument(Name = "Addend", 
                   Description = "is the second number that will be added")]     
    double v2)
{
    return v1 + v2;
}

we get both the function description

Function Description

and when selecting the function, we get argument help

Argument Help

That looks nice, but it's all still very flaky, only works on my machine and sometimes crashes Excel. It might be a start, though...


Update 9 May 2014:

I've made some progress figuring out how to make the argument help work under older Excel and Windows versions. However, it still needs quite a lot of work to get everything reliable. Anyone who would like to help with this should please contact me directly.


Update 18 June 2016:

Excel UDF IntelliSense support for both Excel-DNA add-ins and VBA functions is now being tested. See the Getting Started page on GitHub for instructions.

Govert
  • 15,501
  • 3
  • 56
  • 68
  • Sadly, it does seem like Excel 2013 or Windows 8 or both are required for the UI Automation TextRange support that the argument help uses. I'd love to hear from anyone who has some Windows UI Automation experience ... – Govert Jul 08 '13 at 12:59
  • Did you try to reference older Excel assemblies before compiling to older machines? – Daniel Möller Jul 10 '13 at 11:35
  • 1
    References to the Excel object model are not really involved in this. But there are certainly different UI Automation versions which might affect things... – Govert Jul 10 '13 at 11:37
  • 1
    This is streets ahead of anything out there so far, so you get my vote for the bounty. I intend to see if I can contribute to this solution in the near future so keep an eye out for my pull request! – Alain Jul 10 '13 at 15:17
  • @Alain Good job to Govert! & Alain I'd love to see you master this. – CodeCamper Jul 11 '13 at 21:18
  • Alain and @Govert, do you have any updates on this to share? I personally find it really annoying that tooltips are not possible for UDFs – Jeanno Apr 13 '15 at 15:20
  • @Jeanno - There is ongoing (but slow) progress at https://github.com/Excel-DNA/IntelliSense. I don't think there are known showstoppers left, but it's not quite baked yet. – Govert Apr 13 '15 at 21:59
1

How about

  1. Capture inputting text on key press event of cell. like this
  2. Check if the text matches with custom functions.
  3. If matches, then show something like label or shape to pretend be a tooltip. like this

Is this acceptable?

It is a little ugly but easier.

Community
  • 1
  • 1
Clxy
  • 435
  • 5
  • 12
  • This is an interesting starting point that I considered, but ran into complications when more advanced forms of editing a formula are encountered (such as clicking somewhere in the middle and deleting/adding characters, or highlighting and overwriting a part of the formula, or using a custom formula in the middle of some other formula.) These require more than checking key-presses, we'd need to be looking at the current contents of the formula bar or cell in mid-edit. This too might be accomplished with some imported dll libraries and handle getting hackery. Certainly worth exploring. – Alain Jul 03 '13 at 16:27
-1

What is XLL?

An XLL is a DLL that exports several procedures that are called by Excel or the Excel Add-in Manager. http://msdn.microsoft.com/en-us/library/office/bb687861.aspx

How you develop the XLL?

Excel XLL SDK with Visual C++ (or anything that can compile a DLL and call the SDK procedures)

Where I can find a quick guide for creating a simple XLL?

http://support.microsoft.com/kb/178474

How I get tooltips?

  1. Implement your function as a procedure and export it
  2. Implement and export procedure xlAutoOpen(void) - http://msdn.microsoft.com/en-us/library/office/bb687860.aspx
  3. xlAutoOpen just needs to call xlfRegister - http://msdn.microsoft.com/en-us/library/office/bb687900.aspx
  4. For tooltips, special attention for: pxArgumentText, pxFunctionHelp, pxArgumentHelp1

Sadly, the Analysis Toolpak add-in doesn't have tooltips either.

My solution was wrong, but with wrong information posted by the original poster. Showing a picture with BINOMDIST, if his link clearly shows that this is not a function of ANALYS32.xll.

This means I was trying to solve an impossible question. Because there is no XLL that can do what the poster requested. If you find a version of Excel that show tooltips of XLLs, please let me know.

About what the poster asked, trying to mimic the XLL behavior, I am sure my answer was the most correct in relation of what ANALYS32.xll do.

Marcos Zolnowski
  • 2,578
  • 1
  • 24
  • 28
  • 3
    Sadly, registering a UDF with xlfRegister does _not_ cause Excel to display that information as in-sheet intellisense tooltips. The descriptions etc. registered there are shown only in the Function Arguments dialog box, which pops up when you press the fx button. But that's not what the original poster is asking about. – Govert Jul 10 '13 at 08:49
  • @Govert is it still this way now in 2016? – beppe9000 Jun 19 '16 at 20:22
  • @beppe9000 Yes. You can get in-sheet IntelliSense tooltips for UDFs (defined in an XLL or VBA) using the Excel-DNA IntelliSense extension: https://github.com/Excel-DNA/IntelliSense – Govert Jun 19 '16 at 21:45