Is it possible to exit Excel completely from a macro?

G

Guest

I'm trying to run a auto open macro that will open a second workbook, save
data there and then shut down Excel completely. Is this possible?
 
G

Guest

Application.quit

if you want to save stuff first
For Each w In Application.Workbooks
w.Save
Next w
Application.Quit
 
W

WATYF1

Not sure what you mean by "save data there", but this code will Open a
new workbook... save it to a directory... then close all open workbooks
and exit Excel.


Sub Test()

Dim wrk As Workbook

Set wrk = Workbooks.Add
wrk.SaveAs "C:\Blah\Blah.xls"
Application.Workbooks.Close
Application.Quit

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top