Hello–
I'm trying to make a copy of an excel file (based on a template) and place the new file in a different folder. I was wondering if this error could be diagnosed…The error is:
Unable to resolve the name workbooks.Open.
Error in Excel_experiment (line 5)
wbsource = workbooks.Open('E:\Users\bpeoples\Downloads\MATLAB GLOSS
MEASUREMENTS\TemplateExcelFile\Template_Lightness.xlsx');
My code is as follows:
clcclose allclear allexcel = actxserver('Excel.Application'); %start excelwbsource = workbooks.Open('C:\Users\bpeoples\Downloads\MATLAB GLOSS MEASUREMENTS\TemplateExcelFile\Template_Lightness.xlsx');wbdest = workbooks.Open('C:\Users\bpeoples\Downloads\MATLAB GLOSS MEASUREMENTS\Excel Files\someotherexcelfile.xlsx');ws = wbsource.Worksheets.Item('NameOfSheet'); %or you can you the sheet index: ws = wbsource.Worksheets.Item(index);ws.Copy(wdest.Worksheets.Item(1)); %copy worksheet before 1st worksheet of destination workbookwdest.Save %save destination workbookexcel.Quit %quit excel
Best Answer