closing excel after closing a workbook

  • Thread starter Thread starter CWalsh
  • Start date Start date
C

CWalsh

Hi all,
I would like to be able to close active workbook (without saving) and
then close Excel completely via a button on a userform.
At present I use the following to close the workbook but this leaves
Excel running.
ActiveWorkbook.Close False
Thanks in advance
chris
 
Chris,

Use

Application.Quit

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hi, the following code would do, what you need :

Sub closeAndQuit()

Dim xlAp As Application

Activeworkbook.Saved = True

Set xlAp = ActiveWorkbook.Application

xlAp.Quit

End Sub

In this case, your workbook won't be saved and the Excel applicatio
will quit.

If You wish to save the activeworkbook before closing Excel, you shou
try this instead of "Activeworkbook.Saved = True" :

ActiveWorkbook.Save (if it's saved before)
or
ActiveWorkbook.SaveAs FileName:="Filename.xls"

but remember, if you have more than one Workbooks, it should've bee
done for each one
 
Dear Tolgag
Your answer was great - I have used this and now when I alt-crt-del the
excel process no longer shows as running.
Thank you so much
C
 
Back
Top