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:


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
    pbAltF4 = False
End If

End Sub

Hope it helps