0

Im trying to make a joke program and am wondering what the script is to open a new file (ie. the one currently running) when you click on a button :?: . Also is ther anyway to disable the alt-f4 command or make it so that when the program is exited it opens a specified program :?: .

Any help will be apreciated. :cheesy:

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by williamrojas78
0

Hi

This shows you how to determine if ALT+F4 was pressed

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

   If (KeyCode = vbKeyF4) And (Shift And vbAltMask) Then
      'ALT+F4 pressed
      'Set a form-level flag (to be read by code below)
        pbAltF4 = True
   End If

End Sub

This shows you to prevent user from exiting if ALT+F4 is pressed.

Private Sub Form_QueryUnload(Cancel As Integer, _
   UnloadMode As Integer)

'When ALT+F4 is pressed,
'UnloadMode is set to vbFormControlMenu 

If pbAltF4 And UnloadMode = vbFormControlMenu Then
    Cancel = True
    'reset
    pbAltF4 = False
End If

End Sub

Hope it helps

regards

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.