Problem with optional parameters in Excel Automation Add-in worksheet function

M

Mike Gilkeson

I'm developing an Office Automation Add-in in C++/ATL (Visual Studio
..NET 2003) that exposes an Excel worksheet function. The function
takes 13 input parameters and I need 9 to be optional. I used the
optional attribute for the parameters in the IDL function declaration:

[id(1), helpstring("method TestFunction")] HRESULT TestFunction([in]
VARIANT RequiredParam1, [in] VARIANT RequiredParam2, [in] VARIANT
ArgumentList, [in] VARIANT Argument1, [in, optional] VARIANT
Argument2, [in, optional] VARIANT Argument3, [in, optional] VARIANT
Argument4, [in, optional] VARIANT Argument5, [in, optional] VARIANT
Argument6, [in, optional] VARIANT Argument7, [in, optional] VARIANT
Argument8, [in, optional] VARIANT Argument9, [in, optional] VARIANT
Argument10, [out,retval] VARIANT* returnValue);

When I run Excel the function shows up correctly. The function window
shows the first 4 parameters names in bold (meaning required) and the
rest not in bold but my code doesn't get called unless I fill in all
the parameters. I created Microsoft's sample Visual Basic Automation
Add-in, http://support.microsoft.com/default.aspx?kbid=285337, that
has a function with an optional parameter and the sample worked
correctly. I also tried calling my method from VB and that also worked
correctly (I didn't have to supply the optional parameters). Does
anyone have any idea what's wrong with Excel calling my method?


Thanks,
Mike Gilkeson
 
J

Jonathan Rynd

(e-mail address removed) (Mike Gilkeson) wrote in
I'm developing an Office Automation Add-in in C++/ATL (Visual Studio
.NET 2003)

You might also want to post to excel.programming.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top