Excel controls in VSTO

By | January 12, 2018

I am looking for a control that does the same as the user Defined Function control in Excel

So for example when you click on “Average”, a control pops up allowing you to type in 2 numbers in text boxes. In the right hand side of the text boxs there is a button that when clicked allows you to select a range of values in excel and when selected, fills the text box.

Anyone know of a VSTO or any other control that does this so I don’t have to code it myself?


It does exist, but it’s not exactly the same as the one you will find in Excel.
Get your hands on the Application object and call the InputBox method. This methods can show several modal input dialogs of different types. Type 8 is the Range selection type, this type 8 dialog has a big textbox, an OK button and a cancel button (but it’s missing the usual range selection icon). When the user clicks ok the selected range is validated and the inputbox box method returns the result.Like in the “real range dialog”, the user is able to only selected Ranges while this modal dialog is open.


Application.InputBox("Select a Range","title",Type.Missing,Type.Missing,
                              Type.Missing,Type.Missing,Type.Missing, 8);

Then use the returned range to display in the TextBox.


This doesn’t exist. you would have to build it yourself using .net user controls.
In order to get the behaviour right, you might have to switch between modal and non-modal dialogs, for the range selection.

The excel function, description and selection window is not available through VSTO or Excel object model libraries.

Leave a Reply

Your email address will not be published. Required fields are marked *