RunAutoMacros xlClose then Application.Quit

R

Rockee052

Hello,

I posted a question on this before and thought I came up with my ow
solution but, If you are reading this you can tell my solution did no
work :mad: . So I have a couple of questions and would appreciate an
help or suggestions.

1) Can I run an automacro xlclose so, that before excel closes it run
my Workbook_BeforeClose procedure?

2) Reason why I want to run the WorkBook_BeforeClose:
Because I have a custom menu and a duplicate save as dialog box so, i
the user clicks on cancel my menu is not deleted.

3) Can you run an automacro then quit the application?

Here is what I have been working with:


BTW, My keyboard says help him please! I cant take anymore abuse! :mad


'To duplicate excels save dialog box
If Not Me.Saved Then
Dim Msg As String
Dim Ans As Integer
Beep
Msg = "Do you want to save the changes you made to "
Msg = Msg & Me.Name & "?"
Ans = MsgBox(Msg, vbQuestion + vbYesNoCancel)
Select Case Ans
Case vbYes
Me.Save
Case vbNo
Me.Saved = True
Case vbCancel
Cancel = True
Exit Sub
End Select
End If
Call DeleteMenu
End Sub

'What I have been using to close the workbook but, I actually want t
close the application via commandbutton.

Private Sub CommandButton3_Click()
With ActiveWorkbook
.RunAutoMacros xlAutoClose
.Close
End With
End Sub

I have tried putting Application.ScreenUpdating = False
and that will work if the user clicks on ok or cancel but if the use
clicks on yes it bring up excels save dialog box.

Summary: Close excel (application.quit) via commandbutton, befor
exiting it will call my custom save dialog.

Again, any suggestion will be MUCH appreciated...

Rockee Freeman
Excel 200
 
D

Don Guillett

Perhaps this will help. I use it to save all open apps>close>& leave excel
Sub CLOSE_ALL()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In Workbooks
w.Save
Next
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