ASP Excel.Application objExcel.Range("range") freezing
Whenever I use this code,
Set oExcel = CreateObject("Excel.Application")
Set oWorkbook = oExcel.Workbooks.Open(sPathToTemplate)
oExcel.Range("shipping_name").Value = strShippingName
oWorkbook.Close()
Set oWorkbook = Nothing
Set oExcel = Nothing
The Excel process on the server is freezing, and the cells are never altered. Or at lea开发者_如何学编程st that's what it seems.
The workbook opens just fine, and if I don't try to change any cell contents, the code completes without error. But when I add the change back in and refresh the page, the EXCEL.exe process comes up in the task manager, and the script stops responding. I have to kill the process manually for it to time out.
Anything I can do to get the code working?
This is possibly due to the fact you are not saving the workbook. On a desktop, this would cause Excel to generate a "Do you want to save the changes?" dialog.
Try adding
oWorkbook.saved = true
before you close the workbook. This will tell Excel to not be concerned with whether the workbook has changed (but won't save the document). If your asp works, then it's the save dialog that's causing the problem. To actually save the changes, you'll need to call one of the
oWorkbook.Save
oWorkbook.SaveAs
methods
精彩评论