View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jack Hoxley [MVP][_2_] Jack Hoxley [MVP][_2_] is offline
external usenet poster
 
Posts: 4
Default Registering parameter/function help for Excel User Defined Fun

Thanks for the quick reply Peter.

The accolade for your "WTF" method, as you describe, belongs to Laurent
Longre, see here
http://xcell05.free.fr/english/index.html
The method is limited to 255 characters of help text in total for the
description and all the arguments.


Yes, I'm familiar with that in my travels (just didn't have the URL to hand
when I posted my original message). Don't get me wrong, I don't wish to knock
Laurent personally for this code - but the technique just seems like a
horrific hack which sets off my alarm bells for integrating this into a
solution used by 1000's of people. I like to have confidence that arbitrary
code from the internet has some sane technical grounding :-)

Firstly, the xlfRegister function (aka REGISTER) seems geared towards
aliasing a native DLL's public functions for use in Excel. That is, a rather
neat way of exposing advanced functionality in a clean Excel manner.
Therefore it seems strange to me that it's being used to expose existing VBA
Macros that don't come from an external and otherwise unusable DLL.

Secondly, the articles online talk about picking system DLL's (for which the
DLL may exist in different places, so you need platform specific "where is
the Windows folder" code) and overriding system functions. You also mention
"you may crash Excel" which is one distinct outcome I can see for
redefining/overriding otherwise standard API functions. Ok, so maybe it
doesn't actually redefine the "host" API, but based on the MSDN documentation
it definitely seems like "undefined behaviour" which, as before, doesn't give
me confidence in this for an enterprise solution.

If you have your own .Net/C# "ordinary" dll you might just as well include
some dummy functions for use with the above methods (instead of say calling
User32.dll).


I will concede that this avoids the second point, so may well be acceptable.
Our code is currently a COM DLL written in C#, so I'll have to investigate
further.



If you are using automation addin
functions, as became available for use in XL2002, the intrinsic method can
also be used with the code in your own app, though function names will
appear twice in the function wizard.


I'm only bothered about Excel 2003 and later for now, so this sounds
interesting. I've seen a couple of articles about exposing C# COM methods
directly to Excel, but they didn't do anything about adding descriptions or
parameter information - would you know of an example of doing this, or what
keywords/APIs are involved?

You can to link to a chm help file without either of the above. Also you can
include 2-3 lines (depending on XL version) of help text to appear in the
function wizard (but not text for each argument). The help link and text can
be added by selecting the function in Object browser, rt-click, properties.
With simple functions the "description" text alone might be enough without
resorting to the methods above. Have a go with that first.


I'll have a look into this, thanks for the suggestion.

AFAIK there are no other approaches to include help text in the function
wizard.


That's "good" to hear - obviously I'd like a nice clean solution, but it's
also good to know I haven't missed anything crucial when reading around.

Thanks again for your help,
Jack