Actxserver unable to locate Excel workbook
    조회 수: 8 (최근 30일)
  
       이전 댓글 표시
    
I am having issues getting the ActiveX application to open an existing Excel doc for editing.
My current code looks like:
file_name = 'Excel_Book.xlsx';
xl = actxserver('Excel.Application');
xlb = xl.Workbooks.Open(file_name);
This returns the error:
Error
Invoke Error, Dispatch Exception:
Source Microsoft Excel
Description: 'Excel_Book.xlsx' could not be found
I know that the file exists, as I can read it with
xlsread(file_name)
I have even changed the MATLAB directory to be seeing the folder with the Excel_Book file in it, and yet the ActiveX refuses to read the document.
Similar problems were encountered using:
xlb = xl.Workbooks.Item(file_name);
or
xlb = xl.get('Workbooks',file_name);
댓글 수: 0
채택된 답변
  Walter Roberson
      
      
 2016년 7월 28일
        It would be safer to use fullfile() to create a fully-qualified file name to request to open.
댓글 수: 3
  Walter Roberson
      
      
 2016년 7월 28일
				[filename, filedir] = uigetfile();
complete_file_name = fullfile(filedir, filename);
추가 답변 (1개)
  Shameer Parmar
      
 2016년 7월 28일
        Try replacing the line and check..
 xlb = xl.Workbooks.Open(file_name);
with
 xlb = xl.Workbooks.Open('fullpath\file_name along with the extension');
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 ActiveX에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


