Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get user to select cells(Range input) in c# vsto excel add-in?

I need is to give the user control to select some cells which'll be used in the program. The interface is easily seen in many of the excel functions like while inserting data to the graphs.

Pre-selected range can be easily accessed as Globals.ThisAddIn.Application.ActiveWindow.RangeSelection but this is not what I am looking into as I need multiple such ranges. I am trying this on visual-studio, There is Interaction.InputBox function to take string in , which is said to be equivalent of Inputbox of vba, but inputbox of vba had parameter for input data type, which c# inputbox doesn't.

The VBA equivalent for this is

Dim rngX as Range
Set rngX = Application.InputBox("Select a cell or a range", "Input Cells", Type:=8)

the Type:=8 will make the inputbox to take range input. but i need to do it in c# (using visual studio) and the Inputbox method of c# doesn't have input type like VBA.

like image 268
Atreyagaurav Avatar asked Oct 31 '25 14:10

Atreyagaurav


1 Answers

Range myRange;

myRange = Globals.ThisAddIn.Application.InputBox("Please select your range?", "Range Selector", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, 8);
like image 114
tariqj Avatar answered Nov 02 '25 03:11

tariqj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!