xlsread can't find file but exist() can

Running Matlab 2014a 64 bit on Windows 7.
Occasionally, when trying to open .xls files using xlsread I get the error:
XLSREAD unable to open file '\\path\subpath\...\filename.xls'. File '\\path\subpath\...\filename.xls'' not found.
the strings I'm using for pathname and filename are generated by using uigetfile, so Matlab can obviously see the files, which I've double checked using the exist function. I'm able to get around the problem by manually opening the Excel files and then closing them (Excel always prompts if I want to save, despite me changing nothing in the file), after which xlsread is successfully able to load the files.
These are .xls files containing macros

Antworten (1)

Sean de Wolski
Sean de Wolski am 19 Dez. 2014

0 Stimmen

Are you creating absolute full file paths with both outputs of uigetfile?
[FileName,PathName] = uigetfile()
fn = fullfile(PathName,FileName)
xlsread(fn)
Otherwise, it could be relative and not found if the current directory changes or similar.

Kategorien

Mehr zu App Building finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 19 Dez. 2014

Beantwortet:

am 19 Dez. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by