How to save an excel file to a specific path using ActiveX controls?

1 view (last 30 days)
I am using writematrix as well as ActiveX controls to import data into a template excel file. I have it set up to where the user chooses the file name to which the editted template file saves, but for some reason it always saves to my Documents folder, no matter what folder I am in when the dialog box pops up and I enter my desired file name. I would like for it to save to either the active folder, or to the folder of my choice so I can further manipulate the file after it is saved.
I guess it is okay that is saves to Documents, but this just seems arbitrary and I don't know if it would save to Documents for every user. Here is the code I originally used, which just saves the excel file to a user-inputted file name to the Documents folder:
newfile = uiputfile('.xlsx');
Workbook.SaveAs(newfile);

Accepted Answer

dpb
dpb on 9 Feb 2021
You don't give a fully-qualified filename; what else is it to do but use system default?
[file,path]=uiputfile('.xlsx');
Workbook.SaveAs(fullfile(path,file));

More Answers (0)

Community Treasure Hunt

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

Start Hunting!