views:

67

answers:

0

I have a C++ .xll addIn for Excel. The following test worksheet function works fine with the xll loaded:

LPXLOPER __stdcall Test()
{
    return &xlstring("Yayage",true)
}

i.e. =Test() returns "Yayage" in the worksheet. xlstring is my own custom method which turns a string into an excel string and specifies whether excel or the xll are responsible for freeing its' memory.

I intend to use VBA to produce a 'GUI companion' AddIn for versions 2003 and previous, and a C# Excel 2007 AddIn project for 2007 onwards. These will both work with a version-independant .xll that communicates with a web service.

Both C# and VBA have the following Excel functions: Application.ExecuteExcel4Macro(string) Application.Evaluate(string) Application.Run(...)

These work fine (Except .Run which, in C#, wants to take 32 parameters) with normal worksheet functions that return strings, e.g. in VBA:

MsgBox Application.<Any above method>("=Trim(""    Billy   Bob       Fred    "")")

Produces a message box containing "Billy Bob Fred"

However, I cannot get this to work with any of my custom worksheet functions. Registering them as commands instead of worksheet functions doesn't work either.

I've tried different styles of function name, with and without = / (), and just about everything else I can think of.

Can anyone help me with this?