Range Selection Dialog in Excel

Add-in Express™ Support Service
That's what is more important than anything else

Range Selection Dialog in Excel
How to sel ect a range fr om an excel Task Pane 
Willem Van Deursen




Posts: 3
Joined: 2012-07-09
Hello,

I have create an Excel AddIn with an Excel Task pane. From the Task Pane I want to be able to select an Excel Range in the current workbook. I did find out about the use of the ExcelApp.Inputbox, using


ExcelApp.InputBox('Caption','Title',EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,8,0);

but seem to be unable to interpret the result of this.

Basically what I am trying to do is something like:

var
MyRange: ExcelRange;
begin
MyRange:= ExcelApp.InputBox('Caption','Title',EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,8,0);
...
end;

Questions: How do I make this work?
Are there other (better) ways to do this?

Kind regards

Willem
Posted 09 Jul, 2012 09:45:01 Top
Andrei Smolin


Add-in Express team


Posts: 14720
Joined: 2006-05-11
Hello Willem,

var
  MyRange: ExcelRange;
  V: OleVariant;
begin
  V := ExcelApp.InputBox('Caption','Title',EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,8,0);
  if TVarData(V).VType = varDispatch then
  begin
    MyRange := ExcelRange(TVarData(V).VDispatch);
    ShowMessage(MyRange.Address[False, False, xlA1, EmptyParam, EmptyParam]);
  end;
end;


I suggest that you check http://stackoverflow.com/questions/101673/alternative-to-excels-refedit-control-that-can-be-used-outside-of-vba. Probably, googling for "alternative refEdit control" will help you to find an even better way.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Jul, 2012 11:21:51 Top