On 2/24/06, Bryan Stevenson <[EMAIL PROTECTED]> wrote: > Thanks Jim....and yes plz....fire me some COM examples. >
First the advice... -Microsoft does not support "headless" automation of the office products -If you are going to do it, read this document: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757 -and I have had the best luck running excel as a specific user... http://support.microsoft.com/kb/288367/ -This is not a robust process, and I have found that excel leaves processes hanging around if it runs in to any trouble...cfexecuting sysinternals pskill.exe utility to clear out the excel processes is sometimes necessary. -Debugging can be a real pain, because if Excel throws an error message, the process just hangs, and you don't know what the error is. Here is the code...I believe the examples I worked off for this were from cfcomet, but it has been a long time...ahh memories... <CFSET excelfile = "c:\temp\someexcelfile.xls"> <CFOBJECT ACTION="CREATE" CLASS="Excel.Application" NAME="objExcel" TYPE="COM"> <CFSCRIPT> // Open Excel in the background objExcel.Visible = False; // Disable client alerts such as: 'Save this workbook?' objExcel.DisplayAlerts = False; // Define the workbooks object objWorkBook = objExcel.Workbooks; // Get the file objOpenedBook = objWorkBook.Open(excelfile); // Get the WorkSheets' collection objWorkSheets = objExcel.WorkSheets; // Open the first worksheet (assuming that is where you data is) objWorkSheet = objWorkSheets.Item(Val(1)); // Set ranges to select a cell and get the value... objRange = objExcel.Range("A1:A1"); //This is the part I'm not completely sure about, because most of my work was setting values, not reading them... mynewvariable = objRange.value; // Close the document objWorkBook.Close(); // Quit Excel objExcel.Quit(); // Release the object objExcel = "Nothing"; </CFSCRIPT> -- Jim Wright Wright Business Solutions [EMAIL PROTECTED] 919-417-2257 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:233420 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

