Error using Interface.000208D7_0000_0000_C000_000000000046/get Invoke Error, Dispatch Exception: El índice no es válido.
2 views (last 30 days)
Show older comments
Cómo puedo solucionar aquel error, ya que si cambio el valor sheet2 = get(Sheets, 'Item', 2); -a- sheet2 = get(Sheets, 'Item', 1); No aparece el error pero yo quiero crear la segunda hoja y guardar ahí un gráfico.
El gráfico antes hecho:
x=-2.9:0.2: 2.9; y=exp(-x.*x); plot(x,y)
El código es el siguiente:
function PlotInExcel
FILE = 'C:\victor\test_plot.xls';%.............Archivo
%.............excel COM objetos............................................................................
Excel = actxserver ('Excel.Application');
Excel.Visible = 1;
if ~exist(FILE,'file')
ExcelWorkbook=Excel.Workbooks.Add; %NUEVO LIBRO DE EXCEL
ExcelWorkbook.SaveAs(FILE);
ExcelWorkbook.Close(false);
end
invoke(Excel.Workbooks,'Open',FILE); %Abre la carpeta
Sheets = Excel.ActiveWorkBook.Sheets;
sheet2 = get(Sheets, 'Item', 2);
invoke(sheet2, 'Activate');
Activesheet = Excel.Activesheet;
print ('-f1','-dmeta'); %.................Copiando a los portapapeles
Range ='A1';
ActiveSheetRange = get(ActiveSheet,'Range',Range);
ActiveSheetRange.Select;
ActiveSheetRange.PasteSpecial; %.................pegando la figura en la localización asignada
end
%-----------------------------------fin de la función "PlotInExcel--------------------------------------
0 Comments
Answers (0)
See Also
Categories
Find more on Spreadsheets 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!