Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Importing data in Excel using an ActiveX connection
조회 수: 1 (최근 30일)
이전 댓글 표시
Greetings. I am having difficulties running an automated script makes an Excel worksheet import data from an external .dat file using an activex connection from Matlab. Assuming Excel is my activex object, the following should (I think) make Excel import data from the indicated file path in cell A1:
% UI: Name the .xlsx file to write to
[xlfile, xlpath] = uiputfile('*.xlsx', 'Save Workspace as'); Inputsheet=1;
if isequal(xlfile,0) || isequal(xlpath,0)
disp('User pressed cancel')
else
disp(['User selected ', fullfile(xlpath, xlfile)])
end
filename = [xlpath xlfile]; % file directory
xlswrite(filename,1) % Write a number to the file to make it physical
% Make sure the desired output sheet is clean
% Retrieve sheet names
[~, sheetNames] = xlsfinfo(filename);
% Open Excel as a COM Automation server
Excel = actxserver('Excel.Application');
% Open Excel Workbook
Workbook = Excel.Workbooks.Open(filename);
% Clear the content of the desired output sheet
cellfun(@(x) Excel.ActiveWorkBook.Sheets.Item(x).Cells.Clear, sheetNames(Inputsheet));
% Get a handle to the active sheet
Activesheet = Excel.Activesheet;
Excel.ActiveSheet.Connection.Add(Excel.Activesheet.get ('Range', 'A1'), 'TEXT','C:\Users\isc.ISC1\Desktop\Matlab Programs\GTstrudl Output Postprocessing\WD-ULS-PUNCHING-JACKET-WEAK-LRFD.DAT')
The code gives me the error message "No appropriate method, property, or field Activesheet for class handle.handle."
Any help is greatly appreciated as this problem has been nagging me for a while now!
Thanks in advance, Poul Reitzel
댓글 수: 0
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!