寻求 Excel 自定义函数工具提示 [英] The quest for the Excel custom function tooltip

查看:40
本文介绍了寻求 Excel 自定义函数工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经可用具有与原生 excel 函数相同的工具提示:

当然,如果此信息以某种方式在此 XLL 文件中编码并传递到 Excel,是否可以使用我们自己的加载项复制它?我现在要开始自学一些有关反编译的知识,看看我是否可以对分析工具包中发生的任何事情进行逆向工程.

您如何提供帮助

我几乎可以肯定,我已经研究了有关此问题的所有公开信息.如果有人知道我不知道的可能对此有所帮助的内容,请随时加入.我对反向工程编译的 dll/xlls 非常不熟悉,所以如果有人想打开他们的 Analysis32.xll 的本地副本和弄清楚它的自定义函数定义发生了什么,我将非常感激.否则,我将自己继续深入研究,直到我找到所有死胡同并报告我的发现.

解决方案

我已将一个概念验证项目作为 页面.

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:

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:

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:

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:

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:

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.

解决方案

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

and when selecting the function, we get 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.

这篇关于寻求 Excel 自定义函数工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆