Q:

Trying to close Excel through an Excel macro?

I made a button (not an activeX button) and assigned a macro that is coded to kill the EXCEL.EXE task. When activated it gives me an error message saying it cannot close. Is it even possible to kill the excel task through excel?
Here's my code. I'm positive it works.
Dim oShell : Set oShell = CreateObject("WScript.Shell")
intAnswer = _
MsgBox("Do you want to close Excel?", _
    vbYesNo, "Prompt")

If intAnswer = vbYes Then
    MsgBox "Excel will close."

Else
    MsgBox "Excel will remain open."
End If

oShell.Run "taskkill /im EXCEL.EXE", , True

A:

Use the Application.Quit method : 
intAnswer = _
MsgBox("Do you want to close Excel?", _
    vbYesNo, "Prompt")

If intAnswer = vbYes Then
    MsgBox "Excel will close."
    Application.Quit

Else
    MsgBox "Excel will remain open."
End If

Consider to use as well 
ThisWorkbook.Save

if you want to save the work before closing the application. You can find out more about the Application object here.

