View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
jack jack is offline
external usenet poster
 
Posts: 97
Default Problem with Excel 2000 automation

Are you talking specifically about Excel 2000?
What is the cause of the spreadsheet lock? How to avoid it?
Why are you using Task Manager to terminate process?
Cannot it be done programmatically?
Thanks,
Jack

"Richard Mueller [MVP]" wrote in
message ...

"Jack" <replyto@it wrote in message
...
Hello,
I do not have that problem when using Excel 2002 and up, but
when using Excel 2000 the problem is as follows:
Set moExcelApp = GetObject(, "Excel.Application")
If moExcelApp Is Nothing Then
Set moExcelApp = CreateObject("Excel.Application")
End If

When there is not Excel application running and the code above is
executed, the Excel.EXE starts as a process.
Later, when the user wants to open spreadsheet the spreadsheet will not
open (Excel 2000 only) and the only remedy is to terminate Excel.EXE
process using Task Manager.
How to prevent that situation?
Should I programmatically terminate Excel.EXE process or there is another
way?
Any ideas appreciated,
Jack


I use code similar to:
==========
Set objExcel = CreateObject("Excel.Application")
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

' Code to write to the spreadsheet.

' Save the spreadsheet and close the workbook.
strExcelPath = "c:\Myfolder\MyWork.xls"
objExcel.ActiveWorkbook.SaveAs strExcelPath
objExcel.ActiveWorkbook.Close

' Quit Excel.
objExcel.Application.Quit
========
If I'm only reading the spreadsheet I use:
=========
' Close workbook and quit Excel.
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
==========
If I fail to Quit, I must terminate the excel.exe process in task manager
or the spreadsheet is locked.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--