1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| function pushbutton2_Callback(hObject, eventdata, handles,TestData, Motor, Drive, Comments)
%[TestData, Motor, Drive, Comments] = read_BENG_MotorTestbench;
watchon
drawnow
print -djpeg; %.................Copying to clipboard
FILE = 'C:\test_plot.xls';
Range ='A1';
%.............excel COM object............................................................................
Excel = actxserver ('Excel.Application');
Excel.Visible = 1;
if ~exist(FILE,'file')
ExcelWorkbook=Excel.Workbooks.Add;
ExcelWorkbook.SaveAs(FILE);
ExcelWorkbook.Close(false);
end
invoke(Excel.Workbooks,'Open',FILE); %Open the file
hFig = gcf
hgexport(hFig,'-clipboard')
ActiveSheet = Excel.ActiveSheet;
ActiveSheetRange = get(ActiveSheet,'Range',Range);
ActiveSheetRange.Select;
ActiveSheetRange.PasteSpecial; %.................Pasting the figure to the selected location
watchoff |
Partager