From: Andy on
"Gina Stuessy" <gstuessy(a)gmail.com> wrote in message <i3hhug$bnf$1(a)fred.mathworks.com>...
> For some reason when I use that script, I get an error message saying the document is already open. If I choose to reopen it, it does have the column width set and the font changed, but then when I close the file and try to open it again, it doesn't. It appears this only works the first time it's opened.

Well, if you already have the document open when doing this, then replace the first line with:

e=actxGetRunningServer('excel.application');

Also, if you want to programmatically save and close the file after changing the width, add to the end:

eF.Save;
eF.Close; % close the file
e.Quit; % close Excel entirely

But it is probably a bad idea to use actxGetRunningServer to edit Excel files while they're already open. It is much safer to do this when Excel is closed.
From: Gina on
This is what I have so far:

[FileName,PathName,FilterIndex] = uiputfile(TableFilename);
xlswrite([PathName, FileName], SliceData);
e=actxserver('excel.application');
eW=e.Workbooks;
eF=eW.Open(FileName); % your filename here
eS=eF.ActiveSheet;
eS.Range('B1').EntireColumn.AutoFit; % autofit column A
eS.Range('A1').EntireColumn.Font.Name = 'Times'; % changes font to Times
eF.Save;
eF.Close; % close the file
e.Quit; % close Excel entirely

I'm getting an error that says the Open function doesn't work because the filename cannot be found, even though the file saves correctly.
From: Gina on
Nevermind my previous message, that worked when I put the path name and file name in as inputs instead of just the filename.

Thanks for all the help!
First  |  Prev  | 
Pages: 1 2
Prev: C6416 - Missing Reply
Next: Varargin