I've tried using a 'tasklist' and 'taskkill' approach, but I can't get the 'taskkill' command to only kill one specific workbook, it will nuke all Excel workbooks that are open (even with a filter).
Not sure if there is a good way to use the actxserver to accomplish this?
Thanks in advance, I appreciate the help!
If you don't have it available, there is almost certainly a way to look it
up from the Excel object itself. I'd suggest checking the Microsoft
documentation as the MATLAB Excel and ExcelWorkbook objects are just
wrappers around the COM objects.
"KtotheC " <kto...@nospam.com> wrote in message
news:gn4fgh$rkp$1...@fred.mathworks.com...
"Vadim Teverovsky" <vtev...@mathworks.com> wrote in message <gn4ht9$gef$1...@fred.mathworks.com>...
"KtotheC " <kto...@nospam.com> wrote in message <gn4fgh$rkp$1...@fred.mathworks.com>...
Now, is making Excel do a 'hard' close, and not prompt the user if they want to save changes possible with this approach as well? Also, what if there are two images of Excel running? Thanks again!
"Ilya Rozenfeld" <rozeni...@alum.rpi.edu> wrote in message <gn4iak$fm4$1...@fred.mathworks.com>...
% If you want to save changes
h.WorkBooks.Item(wbkname).Save
% If you want to save changes with different file name
h.WorkBooks.Item(wbkname).SaveAs(filename)
% If you don't
h.WorkBooks.Item(wbkname).Saved = 1;
h.WorkBooks.Item(wbkname).Close;
Normally you wouldn't have two instances of Excel running. If you open the instance from Matlab then you should already have a handle and don't need to use 'actxGetRunningServer'
"KtotheC " <kto...@nospam.com> wrote in message <gn4nn2$jo1$1...@fred.mathworks.com>...
"Ilya Rozenfeld" <rozeni...@alum.rpi.edu> wrote in message <gn6v4l$nfr$1...@fred.mathworks.com>...
>> wbkname = 'whatever';
>> h = actxGetRunningServer('Excel.Application');
>> h.WorkBooks.Item(wbkname).Close;
??? Invoke Error, Dispatch Exception: Invalid index.
"Ilya Rozenfeld" <rozeni...@alum.rpi.edu> wrote in message <gn4iak$fm4$1...@fred.mathworks.com>...
>> wbkname = 'whatever';
>> h = actxGetRunningServer('Excel.Application');
>> h.WorkBooks.Item(wbkname).Close;
??? Invoke Error, Dispatch Exception: Invalid index.
"Ilya Rozenfeld" <rozeni...@alum.rpi.edu> wrote in message <gn4iak$fm4$1...@fred.mathworks.com>...
I need to use Matlab to save and close an Excel file created by another process, and the above code sounds perfect, if it weren't for this error!
"Bin " <bin....@remove.this.newedgegroup.com> wrote in message <hdk58u$atj$1...@fred.mathworks.com>...
Are you using Office 2007 or earlier version?
"Paul " <paul.da...@opg.com> wrote in message <j0mv5n$3a8$1...@newscl01ah.mathworks.com>...