Error: Unable to resolve the name workbooks.Open.
10 次查看(过去 30 天)
显示 更早的评论
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:
clc
close all
clear all
excel = actxserver('Excel.Application'); %start excel
wbsource = 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 workbook
wdest.Save %save destination workbook
excel.Quit %quit excel
0 个评论
采纳的回答
Fangjun Jiang
2020-6-29
编辑:Fangjun Jiang
2020-6-29
After excel = actxserver(), you have not defined "workbooks". Need this?
workbooks= excel.Workbooks;
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!