ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Is there a command line "switch" To close Excel (https://www.excelbanter.com/excel-discussion-misc-queries/41586-there-command-line-%22switch%22-close-excel.html)

Randy Wayne

Is there a command line "switch" To close Excel
 
I am looking for a command line "switch" to exit Excel and/or a batch file
that can be run at a certain time that would look for an open instance of
Excel and close it.


--
Thanks,

Randy

Dave Peterson

You could create a .VBS file that looked like:

dim myXL
On Error Resume Next
Set myXL = GetObject(, "Excel.Application")
If Err.Number = 429 Then
msgbox "Excel is not running"
else
myxl.quit
end If
On Error GoTo 0
Set myxl = nothing

But if you have a workbook that's been changed and not saved, excel will wait
for you to answer the "do you want to save your changes prompt".

And if excel isn't the active application, the excel icon on the taskbar will
blink to get your attention.

======
If you just want to kill excel, you can read a few suggestions in this thread:
http://groups.google.co.uk/group/mic...bc463e2166e781

(one line in your browser)

or
http://snipurl.com/h4wg



Randy Wayne wrote:

I am looking for a command line "switch" to exit Excel and/or a batch file
that can be run at a certain time that would look for an open instance of
Excel and close it.

--
Thanks,

Randy


--

Dave Peterson

Randy Wayne

Dave:

thank you. Yes, being able to save is an issue. I will follow the thread
that you sent.

--
Thanks,

Randy


"Dave Peterson" wrote:

You could create a .VBS file that looked like:

dim myXL
On Error Resume Next
Set myXL = GetObject(, "Excel.Application")
If Err.Number = 429 Then
msgbox "Excel is not running"
else
myxl.quit
end If
On Error GoTo 0
Set myxl = nothing

But if you have a workbook that's been changed and not saved, excel will wait
for you to answer the "do you want to save your changes prompt".

And if excel isn't the active application, the excel icon on the taskbar will
blink to get your attention.

======
If you just want to kill excel, you can read a few suggestions in this thread:
http://groups.google.co.uk/group/mic...bc463e2166e781

(one line in your browser)

or
http://snipurl.com/h4wg



Randy Wayne wrote:

I am looking for a command line "switch" to exit Excel and/or a batch file
that can be run at a certain time that would look for an open instance of
Excel and close it.

--
Thanks,

Randy


--

Dave Peterson



All times are GMT +1. The time now is 02:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com