Hi Chris,
The help file for the XlCall.xl... macros can be downloaded from here:
http://support.microsoft.com/kb/128185.
The Steve Dalton's book (Financial Applications using Excel Add-in
Development in C/C++) is also an awesome guide to the Excel API.
You are calling the DIALOG.BOX function (as XlCall.xlfDialogBox), and
you have it nearly right :-)
The problem is that Excel is not considering the empty strings as the
"blank" values you intend. Instead of the empty strings, you should
pass null, or ExcelDna.Integration.ExcelEmpty.Value or
ExcelDna.Integration.ExcelMissing.Value. These are marshalled to an
XLOPER of type xltypeNil or xltypeMissing, which Excel will accept
here.
The corrected function that displays a dialog box (with the buttons
moved a bit) is:
[ExcelCommand(MenuText="Show Dialog")]
public static void ShowTheDialog()
{
object[,] DialogDef = new object[3, 7] {{null, null, null,
372, 200, "Test", null},
{1, 170, 100, 90, null, "OK",
null},
{2, 270, 100, 90, null, "Cancel",
null}};
XlCall.Excel(XlCall.xlfDialogBox, DialogDef);
}
Regards,
Govert
> I'm struggling to get the Exceldialogbox functionality to work
> properly. I'm using the following code, driven from a menu item:
>
> public static void Run()
> {
> object[,] DialogDef = new object[3, 7] {{"", "", "", 372,
> 200, "Test", ""},
> {1, 100, 170, 90, "", "OK", ""},
> {2, 200, 340, 90, "", "Cancel",
> ""}};
> XlCall.Excel(XlCall.xlfDialogBox, DialogDef);
> }
>
> This gives me the following error in adialogbox:
>
> "Error indialogbox at R1C2".