MATLAB Answers

Can't open excel file on startup

조회 수: 10(최근 30일)
Jack O'Neill
Jack O'Neill 21 Feb 2019
답변: ES 21 Feb 2019
I'm trying to have my computer turn on at a scheduled time, then open MATLAB and run a set script to pull data from a website, process it, and output the results to Excel. I've been able to get everything working except the Excel bit. I've got the following lines to open and load an existing Excel file:
try
e = actxserver('Excel.Application');
eWorkbook = e.Workbooks.Open('C:\Users\USER_NAME_HERE\MATLAB\CoD Data.xlsx');
but it fails at the workbook loading line and gives me the following error in a logfile:
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Microsoft Excel cannot access the file 'C:\Users\USER_NAME_HERE\MATLAB\CoD Data.xlsx'. There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
Help File: xlmain11.chm
Help Context ID: 0
I've tried this with xlsread and gotten the same error. This script is being run 5 minutes or so after I have the computer scheduled to start. This file definitely exists and it's not being opened by any other program at startup. I'm wondering if maybe it's a permissions error or something, but I have no idea how to check or resolve that.
Thanks!

  댓글 수: 0

댓글을 달려면 로그인하십시오.

답변(1개)

ES
ES 21 Feb 2019
Which user opens MATLAB? If "system", then that username might not have access to "C:\Users\USER_NAME_HERE".
Try a path on another drive (say D:/). If it works, then probably its about UAC.

  댓글 수: 0

댓글을 달려면 로그인하십시오.

제품


릴리스

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by