Hi,
I'm hoping someone can help with a GUI i'm building that interacts with an Excel ActiveX object. I'm trying to get my GUI to report the RANGE which has been selected my the mouse, rather than the active cell which forms only one corner of the range.
has been some help, however the function:
ActRange = get(Spreadsheet1,'Range');
Does not appear supported, or if it is, I can't figure out how to extract the value e.g. 'a1:b5'
Does anyone know a work around?
Thanks in advance,
Glenn

 채택된 답변

Friedrich
Friedrich 2012년 2월 29일

2 개 추천

Hi,
as far as I know there is no function for that in EXCEL. You have to get it yourself with the Adress property of the Cell object:
selected_range = [strrep(ex.Selection.Cells.Item(1).Address,'$',''),':',strrep(ex.Selection.Cells.Item(ex.Selection.Cells.Count).Address,'$','')]
Here ex is the handle to the EXCEL automation server.

댓글 수: 5

Glenn Kightley
Glenn Kightley 2012년 2월 29일
Thanks Friedrich.
It appears that all I need is:
strrep(handles.Spreadsheet1.Selection.Address,'$',''));
Cheers,
Glenn
Friedrich
Friedrich 2012년 3월 1일
Right, thats a way easier than my code. Thanks for letting me know.
Virginia
Virginia 2013년 6월 23일
Hi, I'm new at making codes in matlab, can you show me some examples about how to open an excel file from matlab and selecting a range of cells with the mouse so matlab saves this range of cells as a matrix? Thanks!
Image Analyst
Image Analyst 2013년 6월 23일
How do you propose to let the computer know that you have selected the final range? I mean, you could click on various cells, and even highlight some rectangles, before you decide to "go with" the current selection. How do you tell it you're ready to leave Excel and continue with your MATLAB code?
Jean OMB
Jean OMB 2021년 7월 9일
Hi, im learning on how to work with Activex and I was wonedering if any of you guys were able to open an excel file from matlab and select a range of cells with the mouse? if you did, can you show the code?Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2012년 2월 29일

댓글:

2021년 7월 9일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by