Pages

Thursday, June 6, 2013

Excel Pranks and Practical Jokes with VBA

I’ve shared a lot of Excel tips about how to increase your productivity at work but today I thought I would post something a little more fun – how to decrease your productivity! I’m talking about ways to use Microsoft Excel spreadsheets to play pranks, practical jokes, April Fool’s Day kind of stuff on your friends, roommates, and coworkers. The intent is not to harm anyone or hurt their professional careers – this is simply about having some plain ole fun.

A great way to wreak havoc in the workplace is to create a macro that automatically runs when an Excel workbook is opened. You can do this by writing a VBA procedure in the Open event of the workbook by using the Visual Basic Editor. Create a new Excel spreadsheet then press Alt+F11 to launch the VBA Editor. Next, right-click the ThisWorkbook object, and then click View Code.
excel pranks
In the Object list above the Code window, select Workbook. This will automatically create an empty procedure for the Open event like this and you can now add your evil code.

excel practical jokes
To make Excel automatically close itself when the workbook is opened use this:

Private Sub Workbook_Open()

     Application.DisplayAlerts = False
     Application.Quit
End Sub


Here’s a trick that will automatically open Microsoft Word and close Excel:

Sub Workbook_Open()
‘make sure the Microsoft Word Object Library is selected by going to tools>references

Application.Visible = False
Dim wdApp as Word.Application
Set wdApp = New Word.Application
wdApp.Visible=True
Set wdApp = Nothing
Application.DisplayAlerts = False
Application.Quit
End Sub


This is one of my personal favorites; have a message box pop-up asking if the user wants to download the virus they requested. Whether they press the yes or no button the next message tells them the virus has begun downloading!

Private Sub Workbook_Open()

MsgBox "The virus you requested is now ready to download, Do you want to start downloading now?", vbYesNo, "Virus Trojan-x45fju"

MsgBox "The Virus is Now Downloading. You have made the biggest mistake of your life! ByE bYe", , "Begin Virus Download"

End Sub

This function flips the workbook and will make everything on the left now appear on the right side:

ActiveSheet.DisplayRightToLeft = True

To change all cell’s color to black:

Cells.Interior.Color = RGB(0,0,0)

Instead of automatically running a macro on opening a workbook (and making it obvious you did something) you could embed a macro that only runs on certain conditions. A funny prank is a macro to change the size of the Excel window every time the user clicks on a cell:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Application.WindowState = xlNormal

Application.Width = Int(Rnd() * 1000) - 100

End Sub


As you can imagine, the possibilities are nearly endless! Now you may think “All someone has to do is change or delete the code to fix the problem.” Well, you can protect your VBA code so only those with the password can modify it. Go to Tools>VBAProject Properties>Protection. Check the box to lock project for viewing and create a password (and remember it). Now you’re an evil genius!




Of course, if you’re not comfortable using VBA (which I recommend you get comfortable and learn it)  you can always use these old fashioned tricks:

  1. Use find and replace on a document, like replacing “you” with “you idiots”.
  2.  If your coworker has an old school mouse simply remove the ball when they're not around and then sit back and watch the fun when they try to figure out why their mouse isn't working anymore.
  3. Take a screen capture of a roommate’s desktop and save it as a jpg or bmp file. Turn on the Active Desktop, and make sure to turn off "show desktop icons". Change the wallpaper to the screen capture image you just saved and watch as they click away on their "icons" that mysteriously stopped working.
Or, you can use a device like the Phantom Keystroker.

Have you ever used something like this on someone? What’s your best Excel prank?

No comments:

Post a Comment

I'd love to hear from you!
-Nick