Application.Quit doesn't work - EXCEL.EXE still visible in Task Manager

insomniac_ut

New Member
Joined
Sep 15, 2005
Messages
36
Hello,

I am running a process via scheduled task where a batch file opens up an Excel session, loads an XLL, calculates a bunch of numbers, saves the values to a separate file with the date/time stamp, and closes down.

This process works fine apart from the closing down bit. Though Excel itself is not visible any longer, an EXCEL.EXE is still running (with a large memory footprint) in the Task Manager.

The problem is that since this process is repeated on an hourly basis, the scheduled task encounters memory overflow errors due to the ghost Excel threads, unless I physically terminate all the ghsot threads every few hours. This is really inconvenient.

I've researched this a lot, and it looks like it's not an uncommon problem. So I was thinking that one workaround could be to log the PIDs of the processes kicked off by the scheduled task and then run another scheduled task every few hours to go and kill those PIDs.

Can anyone suggest another technique? If not, could anyone point me to some sample code as I don't really know how or where to start.

Thank you.
 
There's no Paste argument for the worksheet.PasteSpecial method...only range.PasteSpecial.

Yes there is. From the Help

<table id="topTable" width="100%"> <tbody> <tr id="headerTableRow1"> <td align="left">
</td></tr> <tr id="headerTableRow2"> <td align="left">XlPasteType Enumeration</td></tr></tbody></table>
Specifies the part of the range to be pasted. Version Information
Version Added: Excel 2007
<table> <tbody> <tr> <th>Name</th> <th>Value</th> <th>Description</th></tr> <tr> <td>xlPasteAll</td> <td>-4104</td> <td>Everything will be pasted.</td></tr> <tr> <td>xlPasteAllExceptBorders</td> <td>7</td> <td>Everything except borders will be pasted.</td></tr> <tr> <td>xlPasteAllMergingConditionalFormats</td> <td>14</td> <td>Everything will be pasted and conditional formats will be merged.</td></tr> <tr> <td>xlPasteAllUsingSourceTheme</td> <td>13</td> <td>Everything will be pasted using the source theme.</td></tr> <tr> <td>xlPasteColumnWidths</td> <td>8</td> <td>Copied column width is pasted.</td></tr> <tr> <td>xlPasteComments</td> <td>-4144</td> <td>Comments are pasted.</td></tr> <tr> <td>xlPasteFormats</td> <td>-4122</td> <td>Copied source format is pasted.</td></tr> <tr> <td>xlPasteFormulas</td> <td>-4123</td> <td>Formulas are pasted.</td></tr> <tr> <td>xlPasteFormulasAndNumberFormats</td> <td>11</td> <td>Formulas and Number formats are pasted.</td></tr> <tr> <td>xlPasteValidation</td> <td>6</td> <td>Validations are pasted.</td></tr> <tr> <td>xlPasteValues</td> <td>-4163</td> <td>Values are pasted.</td></tr> <tr> <td>xlPasteValuesAndNumberFormats</td> <td>12</td> <td>Values and Number formats are pasted.</td></tr></tbody></table>
© 2010 Microsoft Corporation. All rights reserved.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I'm using Excel 2007. Does the following not trigger an error for you?

Code:
Sub test()
    ThisWorkbook.Sheets(1).Cells.Copy
    ThisWorkbook.Sheets(2).PasteSpecial Paste:=xlPasteValues
End Sub
 
Upvote 0
Hello,

I am having the same problem, whereby, my macro runs fine except the application.quit part. The excel program remains open but the workbook is closed.

I had setup a scheduled task to run the excel file at a specific time.

Any help would be greatly appreciated :)

Here is my code:

Code:
Sub Auto_Open()
ActiveWorkbook.SaveAs Filename:="D:\Reports\Avocet\plantdata" & Format(Date,"yyyymmdd") & ".csv", Fileformat:=xlCSV
Application.Wait (Now()+Timevalue("00:00:10"))
ActiveWorkbook.Close SaveChanges:=False
Application.Quit
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,302
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top