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

Respuestas (1)

Sean de Wolski
Sean de Wolski el 19 de Dic. de 2014
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.

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 19 de Dic. de 2014

Respondida:

el 19 de Dic. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by