Modify my VBA to close Excel after 5 sec

DrPancho

Board Regular
Joined
Jun 12, 2015
Messages
80
Hi

Not sure if this is even possible but couldn’t find much info about it.

I would like the below code to include exiting excel after 5 seconds without
prompting to save once the user has answered the msgbox and the worksheet has
moved to “Trojan.exe”

Can this be done?

Thanks in advance


Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
  Cancel = True
  MsgBox "Ah ah ah, you didn't say the magic word!", , "Your request has been denied!"
  Workbooks("TEST.xlsm").Sheets("Trojan.exe").Select
End Sub
Private Sub Workbook_BeforeSave2(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI Then
    MsgBox "Save As is disabled", vbInformation
    Cancel = True
End If
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
ontime is what you need, i think pranks are in the lounge

i'm also of the opinion that

Private Sub Workbook_BeforeSave2(ByVal SaveAsUI As Boolean, Cancel As Boolean)

isn't a legitimate workbook command and you would have to specifically call it
 
Upvote 0

Forum statistics

Threads
1,202,984
Messages
6,052,913
Members
444,612
Latest member
FajnaAli

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top