I am doing some automation with vbscript and everytime I run the script, it leaves the process “EXCEL.EXE” running. How do I prevent that?
Set oFs = CreateObject("Scripting.FileSystemObject") set objExcel = createObject("Excel.Application") set objWorkbook = objExcel.Workbooks.open("C:\test\test.xlsx") for each sheet in objWorkbook.worksheets wscript.echo(sheet.name) set objSheet = sheet next set objSheet = Nothing set objworkbook = Nothing set objExcel = Nothing Set oFs = Nothing
How do I prevent EXCEL.exe from continuing to run after my script exits?
Use this to close Excel as well. Just replace your code after Next with the following.
set objSheet = Nothing 'Tells workbook to close without saving changes. objWorkbook.Close false set objworkbook = Nothing 'Tells Excel Application to quit. objExcel.Quit set objExcel = Nothing Set oFs = Nothing