Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: xlswrite to Excel 2007 problem
Date: Mon, 8 Sep 2008 03:54:01 +0000 (UTC)
Organization: Sandia National Labs
Lines: 32
Message-ID: <ga27kp$e4l$1@fred.mathworks.com>
References: <g9p9j3$a8b$1@fred.mathworks.com> <3194495.1220562582966.JavaMail.jakarta@nitrogen.mathforum.org> <g9pp3u$md5$1@fred.mathworks.com> <g9q30q$20c$1@fred.mathworks.com> <g9rr8r$j6e$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1220846041 14485 172.30.248.35 (8 Sep 2008 03:54:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 8 Sep 2008 03:54:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1316302
Xref: news.mathworks.com comp.soft-sys.matlab:489100



Final note:

I finally had to resort to a small modification to xlswrite.  I opened a blank workbook with Excel 2003, then saved it as "XLTemplateFile.xls".  The modification to xlswrite now opens this template file, then sets up the workbook, and saves the .xls template using the input file name - just like xlswrite.  Here is the small mod I made, just as an FYI (starts at line 207 in xlswrite):

try
    bCreated = false;
 %   if ~exist(file,'file')
 %       % Create new workbook.  
 %       bCreated = true;
        %This is in place because in the presence of a Google Desktop
        %Search installation, calling Add, and then SaveAs after adding data,
        %to create a new Excel file, will leave an Excel process hanging.  
        %This workaround prevents it from happening, by creating a blank file,
        %and saving it.  It can then be opened with Open.
 %       ExcelWorkbook = Excel.workbooks.Add;
 %       ExcelWorkbook.SaveAs(file)
 %       ExcelWorkbook.Close(false);
 %   end
    
    %Open file
    ExcelWorkbook = Excel.workbooks.Open(XLTemplateFile);
    ExcelWorkbook = Excel.workbooks.Add;
    ExcelWorkbook.SaveAs(file)
    bCreated = true;
    ExcelWorkbook.Close(false);
    ExcelWorkbook = Excel.workbooks.Open(file);

Anyway, just wanted to pass that along in the event that anyone else runs into the same issue that I did.

Thanks to everyone that posted suggestions on this thread.

M Lenz