Macro to quit application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was told to create command button and call macro quitapplication, record,
ok and the stop recording, Empty Macro?

The it says edit macro by inserting a line ActiveWorkbookClose after the
comments?

I assume this is in VB but I really dont know where in Vb to enter the
above. Tried everything but no success

Help

Steve
 
Insert ActiveWorkbookClose directly under the last apostrophe, before the
first action recorded - this is what is meant by "after the comments."

HTH
Doug Davey
 
Thanks Doug

I tried as below, probably me being stupid but didnt work, is it in wrong
place?

Sub quit()

'
' quit Macro
' Macro recorded 06/07/2007 by stephenking
'

'
activeworkbookclose
End Sub
 
Perfect placement in the macro - however the syntax is

ActiveWorkbook.Close

notice the period. Also Case sensitive

HTH
 
This doesn't sound like a very nice workbook to me.

I can have multiple workbooks open that you (as a developer) don't know about.
If your workbook tries to close all my workbooks, I could lose data or I could
save data that I didn't want saved.

How will your code handle the other workbooks that are open--will it save them
without asking, then close them? Will it close them without saving?

In either case, I would expect users to come running at you with pitchforks for
the data that got screwed up.

On the other hand if you wanted to close the workbook that has that button, you
could use a line like:

thisworkbook.close savechanges:=true 'or false????

But you still may have the users asking why they lost 2 hours of work or how to
get the original data back that was overwritten.

And the command you may want to use is:

Application.Quit

(don't do it without lots of thought for your co-workers)
 
ps.

Activeworkbook.close

will try to close the workbook that's active--not the workbook with the code.

Thisworkbook.close

will try to close the workbook that owns the code.
 
Thanks Steve, that worked perfect

One more thing if you can help please

I want Excel to open at a certain worksheet (Main menu-Splash screen)

Could you help me with where to place code and what code is

Thanks

Steve King
 
Back
Top