From: Jacob Schmidt on
I am trying to write multiple portions of a matlab structure(FullSoln) to a new excel spreadsheet(SaveFileName) using the xlswrite command. The problem arises when matlab first runs the xlswrite command and it returns the error:

>xlswrite(SaveFileName, FullSoln.NormalVelocity, 'NormVelocity');

??? Invoke Error, Dispatch Exception:
Source: Microsoft Office Excel
Description: The file could not be accessed. Try one of the following:

-Make sure the specified folder exists.
-Make sure the folder that contains the file is not read-only.
-Make sure the file name doesn not contain and of the following characters: < > ? [ ] : | or *
-Make sure the file/path name doesn't contain more that 218 characters.
Help File: C:\Program Files\Microsoft Office\Office12\1033\XLMAIN11.CHM
Help Context ID: 0

It would seem that the xlswrite does not like to create a new file. When I manually create a blank worksheet in the correct directory with matching filename the script runs to completion successfully, however when the file is not created manually ahead of time I recieve this error. I have read a little of other peoples problems with this command and there seems to be some discussion about the filename being an actual path or folder and not a filename. Any suggestions on this is greatly appreciated. Thanks.

Cheers,
Jake
From: ImageAnalyst on
Jake:
Assuming you have no illegal characters in there, you can call
exist(folderName, 'dir') to see if the folder where you want to place
the file exists. If it doesn't call mkdir(). With mkdir() you can
give the full path - you don't have to create child after child to get
down to the folder level you need - you can do it all in one shot.

From: us on
"Jacob Schmidt" <jschmidt(a)spectralenergies.com> wrote in message <hpfhdg$k11$1(a)fred.mathworks.com>...
> I am trying to write multiple portions of a matlab structure(FullSoln) to a new excel spreadsheet(SaveFileName) using the xlswrite command. The problem arises when matlab first runs the xlswrite command and it returns the error:
>
> >xlswrite(SaveFileName, FullSoln.NormalVelocity, 'NormVelocity');
>
> ??? Invoke Error, Dispatch Exception:
> Source: Microsoft Office Excel
> Description: The file could not be accessed. Try one of the following:

it's the SHEET_NAME option, which causes problems...
in r2010a you'll simply get this sequence of warnings but the file is created...

if ~exist('foo.xls','file')
xlswrite('foo.xls',1,'newsheet','a1:a1');
end
%{
Warning: Added specified worksheet.
> In xlswrite>activate_sheet at 294
In xlswrite>ExecuteWrite at 249
In xlswrite at 207
%}

which ML version do you have(?)...

us