views:

415

answers:

1

I'm trying to rewrite some VBA code in Excel VSTO.

The VBA code is as follows:

Application.Dialogs(xlDialogSort).Show

When I try to do the same in VSTO I find that the same method needs 30 arguments! The signature is "Show(object Arg0,object Arg1, etc.)"

Globals.RiskViewerWorkbook.ThisApplication.Dialogs[XlBuiltInDialog.xlDialogSort].Show(null,null,null,... );

What values do I need to pass to make the same call as the VBA code is using? null does not work.

I started writing this question and then discovered the answer so I'll post it and an answer.

A: 

The solution was to pass the value "missing" as each of the arguments.

http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook.displaydrawingobjects(VS.80).aspx

this.Application.Dialogs[Excel.XlBuiltInDialog.xlDialogSort].Show(
    missing, missing, missing, missing, missing, missing, missing, missing,
    missing, missing, missing, missing, missing, missing, missing, missing,
    missing, missing, missing, missing, missing, missing, missing, missing,
    missing, missing, missing, missing, missing, missing);
Paul Hollingsworth
If your going to use methods like this alot, some options include refactoring the call into another method that takes only the parameters you need, or using the Extensions library (not useful for all such methods).
Anonymous Type