Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Wav Warning Upon Attempt to Close Userform

Hi, everyone -

While watching one of my staff use my rent calculation tool this
morning, I noticed that when the initial splash screen appeared, she
would just close the "X" Close button in the upper right hand corner.
I want to prevent this.

I did my Search (proud of me, heh???), and found the exact code I
needed. To enforce the msg box, I also want to include a wav if the
Close button is pressed. I, kind of, messed with my code below, but it
doesn't seem to work ---looking to have the wav play at the same time
as the msg box.

Private Sub UserForm_QueryClose _
(Cancel As Integer, CloseMode As Integer)
'Prevents use of the Close button'

Application.ScreenUpdating = True
DoEvents
ActiveSheet.Shapes("object 204.wav").Select
Selection.Verb Verb:=xlPrimary

If CloseMode = vbFormControlMenu Then
MsgBox "YOU SHOULD NOT BE CLOSING THIS FORM!!!"
Cancel = True
End If
End Sub

Any help would be fantastic.

Thanks,

Golf
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Wav Warning Upon Attempt to Close Userform

Hello Golf,

I am pretty sure I found this code in this forum. I haven't tested, but it
looks right.

Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

Sub PlayMe1()
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Dim retval As Long
retval = PlaySound("C:\My folder\my subfolder\wav1.wav", _
0, SND_ASYNC Or SND_FILENAME)
End Sub

HTH, Greg

"golf4" wrote in message
om...
Hi, everyone -

While watching one of my staff use my rent calculation tool this
morning, I noticed that when the initial splash screen appeared, she
would just close the "X" Close button in the upper right hand corner.
I want to prevent this.

I did my Search (proud of me, heh???), and found the exact code I
needed. To enforce the msg box, I also want to include a wav if the
Close button is pressed. I, kind of, messed with my code below, but it
doesn't seem to work ---looking to have the wav play at the same time
as the msg box.

Private Sub UserForm_QueryClose _
(Cancel As Integer, CloseMode As Integer)
'Prevents use of the Close button'

Application.ScreenUpdating = True
DoEvents
ActiveSheet.Shapes("object 204.wav").Select
Selection.Verb Verb:=xlPrimary

If CloseMode = vbFormControlMenu Then
MsgBox "YOU SHOULD NOT BE CLOSING THIS FORM!!!"
Cancel = True
End If
End Sub

Any help would be fantastic.

Thanks,

Golf



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Wav Warning Upon Attempt to Close Userform

Hi, Greg -

Thanks for your response. When you try to write these code strips at
around 12:00 midnight, your brain isn't necessarilly moving on all
thrusters.....

Right after I posted my query, I remembered that I first needed to
unprotect the sheet where I had my object embedded. Once I did this,
it worked fine. I've posted the code I worked up down below:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
'Prevents use of the Close button'

If CloseMode = vbFormControlMenu Then

Sheets("data_entry_sheet").Unprotect ("led52not")
Application.ScreenUpdating = True
DoEvents

ActiveSheet.Shapes("object 211.wav").Select
Selection.Verb Verb:=xlPrimary
Sheets("data_entry_sheet").Protect ("led52not")

MyTimer = Timer

Do
Loop While Timer - MyTimer < 2

MsgBox "YOU SHOULD NOT BE CLOSING THIS SCREEN IN THIS FASHION!!!"

Cancel = True
End If
End Sub

Using this code, my warning wav will play then pop up the msgbox when
one of my employees tries to "X" out of my initial splash screen.

Thanks for the help,

Golf




"Greg Koppel" wrote in message ...
Hello Golf,

I am pretty sure I found this code in this forum. I haven't tested, but it
looks right.

Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

Sub PlayMe1()
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Dim retval As Long
retval = PlaySound("C:\My folder\my subfolder\wav1.wav", _
0, SND_ASYNC Or SND_FILENAME)
End Sub

HTH, Greg

"golf4" wrote in message
om...
Hi, everyone -

While watching one of my staff use my rent calculation tool this
morning, I noticed that when the initial splash screen appeared, she
would just close the "X" Close button in the upper right hand corner.
I want to prevent this.

I did my Search (proud of me, heh???), and found the exact code I
needed. To enforce the msg box, I also want to include a wav if the
Close button is pressed. I, kind of, messed with my code below, but it
doesn't seem to work ---looking to have the wav play at the same time
as the msg box.

Private Sub UserForm_QueryClose _
(Cancel As Integer, CloseMode As Integer)
'Prevents use of the Close button'

Application.ScreenUpdating = True
DoEvents
ActiveSheet.Shapes("object 204.wav").Select
Selection.Verb Verb:=xlPrimary

If CloseMode = vbFormControlMenu Then
MsgBox "YOU SHOULD NOT BE CLOSING THIS FORM!!!"
Cancel = True
End If
End Sub

Any help would be fantastic.

Thanks,

Golf

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
HOW to close a userform using a button CC Excel Discussion (Misc queries) 2 October 10th 08 02:06 PM
Close automatically a userform FARAZ QURESHI Excel Discussion (Misc queries) 4 January 7th 07 07:46 PM
Userform + close button Chip Smith Excel Discussion (Misc queries) 2 April 1st 06 09:35 AM
Warning message on file close Lambtwo Excel Worksheet Functions 1 October 25th 05 03:31 AM
Close Button on Userform Jean-Paul Viel Excel Programming 0 September 20th 03 06:44 PM


All times are GMT +1. The time now is 10:18 PM.

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

About Us

"It's about Microsoft Excel"