Brian,
Although I've experienced pretty much what you describe, I've never seen the
process actually killing the CF Service itself.
To fix the problem of inactivity in the excel part of the process on
subsequent attempts, use the following:
<CFSET CFUSION_DISABLE_DBCONNECTIONS("datasourcename", 1)>
<CFSET CFUSION_DISABLE_DBCONNECTIONS("datasourcename", 0)>
Which should help to kill any locked connections to the sheet.
HTH,
Dave
-----Original Message-----
From: Brian Ferrigno [mailto:[EMAIL PROTECTED]]
Sent: 30 September 2002 16:40
To: CF-Talk
Subject: COM help
I need help tracking down an error in using CFOBJECT to create a csv file
from an excel spreadsheet.
I am using CF to open up an excel spreadsheet and then trying to turn the
data into a csv file. The code i'm using works fine the first time the
application is launched but on subsequent tries nothing happens. According
to the company hosting my site COM is causing the CF service to fail then it
has to be restarted. I'm listing the code i'm using below.
Is this an issue with a patch needing to be installed or a problem with the
code below? Any help would much appreciated. Thanks.
-Brian
Stats
------
CF version CF5.0
IIS
Windows 2K server
Code
----
<cftry>
<cfobject
action="CONNECT"
class="Excel.Application"
name="objExcel"
type="COM">
<cfcatch>
<cftry>
<cfobject
action="CREATE"
class="Excel.Application"
name="objExcel"
type="COM">
<cfcatch type="Object">
Cannot create Excel Object
<cfabort>
</cfcatch>
</cftry>
</cfcatch>
</cftry>
<cftry>
<cfscript>
// this code will open up the excel spread sheet and then save it as a CSV
file.
// HTML file path
ExcelFilePath = "#attributes.excelFileIn#";
// Destination path for new Word document
// We leave off the extension since we'll declare the file type later on
CSVFilePath = "#attributes.CSVFileOut#";
// Open Word in the background
objExcel.Visible = false;
// Disable alerts such as: 'Save this document?'
objExcel.DisplayAlerts = false;
// Get the 'Documents' collection
objBooks = objExcel.workbooks;
// Open the HTML document
objBook = objBooks.Open(ExcelFilePath);
// Get the sheets collection
objSheets = objBook.WorkSheets;
// Get the first sheet
objSheet = objSheets.Item(Val(1));
// Get a named sheet
objSheet = objSheets.Item("#attribtues.sheetName#");
/* Save it as a new document -- the extension will automatically
be appended based on the file type we choose.
Some of the file types to convert to:
1 = .xls
3 = .txt (tab delimetered
6 = .csv
*/
objSheet.SaveAs(CSVFilePath, Val(6));
// The next line would convert it to RTF instead
// objSpreadSheet.SaveAs(CSVFilePath,Val(6));
// Close the document
objBook.Close();
// Quit Word
objExcel.Quit();
if (attribtues.showConfirmation EQ 1) {
writeOutput("<font size=""-1""
face=""Verdana,Geneva,Arial,Helvetica,sans-serif""><b>File Created:</b>
""#attributes.CSVFileOut#"" <b>from file:</b>
""#attributes.excelFileIn#""<p></font>");
}
</cfscript>
<cfcatch>
<!--- error creating file --->
<font face="Verdana,Geneva,Arial,Helvetica,sans-serif" size="-1">there was
an error creating your new CSV filesfrom your Excel Spreadsheet</font>
</cfcatch>
</cftry>
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists