How to open an excel file from the listbox(having a number of excel files) in gui(GUIDE)?

3 views (last 30 days)
Hi, I have made a gui(having a pushbutton and a listbox).I am using the pushbutton to select some excel files from a directory(in My computer)and showing them in listbox.Now I want to open excel files from the listbox by clicking the respective file.Please tell me how to use 'winopen' function and where to use it(under callback function of listbox or under pushbutton callback function(here I have written the code for opening the window to select files and then displaying them in listbox).Thanks for your help.

Answers (2)

Image Analyst
Image Analyst on 9 Oct 2014
Like I said in your other discussion:
% Get a list of indexes in the listbox that the user has selected.
Selected = get(handles.lstExcelFiles, 'Value');
% If more than one is selected, bail out.
if length(Selected) > 1
return;
end
% If you get to here, exactly 1 is selected.
% Now, get a list of all the items in the listbox.
ListOfFileNames = get(handles.lstExcelFiles, 'string');
% Get the name of the one particular file that has been selected.
baseFileName = strcat(cell2mat(ListOfFileNames(Selected)));
% Get the full file name by prepending the folder where the files live.
excelFullFileName= fullfile(folder, baseFileName);
% Open file in Excel.
winopen(excelFullFileName);

Muhammad Hussain
Muhammad Hussain on 13 Oct 2014
Thank you very much.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!