View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Using the red X (Upper right hand corner) for another purpose.

Ok. Here are the answers to your questions.
Is the Referrals workbook the only one open? - Yes
Where is the Exit_Referrals sub located? - I t resides in module 1
Why do you add vbCr to your message Prompt? - To start a new line in
the message. (Open to suggestions)
Here is the before close code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Part of code to call a pop up calendar.
On Error Resume Next
Application.OnKey "+^{C}"
Application.CommandBars("Cell").Controls("Insert Date").Delete
Call Exit_Referrals
End Sub

I compared the original post to what I currently have, & noticed a big
difference. I am SO SORRY. Here is the current code:

Option Explicit

Sub Exit_Referrals()
Dim MsgBoxResult As String
If MsgBox("Would you like to Exit the Referral Workbook?" & vbCr,
vbYesNo, "Voc. Rehab. - Referral") = vbNo Then
Exit Sub
Else
Sheets("TOC").Select
Application.Calculation = xlCalculationAutomatic
ThisWorkbook.Close SaveChanges:=True
Application.Quit
End If
End Sub
Regarding "Why are you NOT using a global variable to track if the
MsgBox result has already been trapped?" _ I did not know about global
variable.


Ok, that helps!

If you close the workbook itself -OR- if you quit Excel while the workbook is
open the workbook's _BeforeClose event fires. Other things are already in place
for it to send keystrokes, and delete a custom menu added to the Cells
commandbar. Where's the code to set this up?

Better:
Can you post a download link where I can retrieve a copy of the Referrals
workbook with 'dummy data' and detailed comments about what it does? (Assumes
this workbook performs task-specific processes that are fiscal period related)
If so, I'll review/revise it for optimal efficiency and post a link for
download.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion