Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issues quitting Excel 1

Status
Not open for further replies.

fredmartinmaine

IS-IT--Management
Mar 23, 2015
79
US
In a vbscript, I open an Excel file to read a few items from it, then close it. I make no changes. However, even though I quit Excel, the process stays in Task Manager, until my script exits.

Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Visible = False
Set ExcelFile = objExcel.Workbooks.Open(PathAndFileName)
Set WkSheet = ExcelFile.Worksheets(1)   ' assume first tab

  'read data from a few cells, like:
  Content = WkSheet.Cells(2,3)

objExcel.DisplayAlerts = False
ExcelFile.Close FALSE
objExcel.Application.Quit
Set objExcel = Nothing

MsgBox("test pause")
wscript.quit

No matter how long I sit at "test pause" the Excel process stays in Task Manager. When I move on and the script quits, the Excel process dies. Why is that? I have similar issues with Outlook, but it goes grey in Task Manager and never dies. I'll save that for a later discussion.
 
Well, that's an improvement. I modified the closing to un-set WkSheet and ExcelFile. That seems to work fine.

ExcelFile.Close FALSE
Set WkSheet = Nothing
Set ExcelFile = Nothing
objExcel.Application.Quit
Set objExcel = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top