Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Workbook_beforeclose +msgbox


Thanks, Sharad, that helped a bit. Now Excel doesn't ask to save, bu
the message box still pops up one more time after pressing "no".

Phoeni

--
Phoeni
-----------------------------------------------------------------------
Phoenix's Profile: http://www.excelforum.com/member.php...nfo&userid=292
View this thread: http://www.excelforum.com/showthread.php?threadid=27038

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default Workbook_beforeclose +msgbox

Insert a Module in the project. In the module just put following single line
to define a Public Variable 'norepeat'
-x-
Public norepeat As Integer
-x-

(Public variables must be defined at module level.)

Then change the beforeclose code as under:-

-x-
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim UserResponse As String

If norepeat = 1 Then Exit Sub
UserResponse = MsgBox("Remember to HIDE and PROTECT. Do you want to save
before closing?", vbYesNoCancel)
If UserResponse = vbYes Then
Me.Save
End If
If UserResponse = vbNo Then
norepeat = 1
Me.Close SaveChanges:=False
End If
If UserResponse = vbCancel Then
Cancel = True
End If

End Sub
-x-

Sharad


"Phoenix" wrote in message
...

Thanks, Sharad, that helped a bit. Now Excel doesn't ask to save, but
the message box still pops up one more time after pressing "no".

Phoenix


--
Phoenix
------------------------------------------------------------------------
Phoenix's Profile:
http://www.excelforum.com/member.php...fo&userid=2921
View this thread: http://www.excelforum.com/showthread...hreadid=270386



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Workbook_BeforeClose Ed Davis[_2_] Excel Discussion (Misc queries) 21 September 26th 09 01:01 AM
Workbook_BeforeClose Question Sashi Excel Worksheet Functions 7 July 26th 07 08:36 PM
Workbook_beforeclose +msgbox Phoenix Excel Programming 1 October 19th 04 09:44 AM
Workbook_BeforeClose Don Guillett[_4_] Excel Programming 1 August 31st 04 02:27 PM
Workbook_BeforeClose JimP Excel Programming 1 July 5th 04 10:39 PM


All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"