VBA April Fools Office Prank

xcelljunkie

New Member
Joined
Feb 27, 2013
Messages
9
Hi All,

I know this is slightly out of the normal range of questions/posts usually made, but I'm hoping this will be a fun challenge that everyone can participate in. I'm trying to prepare early this year for a great April fools prank for my pals at the office. I'm known as the excel guy at work, so i think it only fitting that I use excel as my means of delivery. What I have come up with so far is a scheme to save an addon or code to their personal macro workbook that will only begin running on April 1st. Otherwise it would be obvious that I am the culprit. I'm thinking any one or a combination of the following.
1.Playing a fart noise/or other sounds whenever they close a workbook or something of that nature.
2.Turning on the "Speak cells" function every so often. (It is likely that they will call me in as it is excel related. I will non-nonchalantly tell them I can fix it, only to have the macro turn it back on a little later.)
3.Anything else that your imaginative brains can come up with.

Rules:
1.Aside from starting some other program to make a noise or something, it must only affect excel.
2.Nothing that will cause will cause anybody to lose any work, which includes the loss of the back button. I planned on getting around this by only using triggers that already disable the back button, ex: closing a workbook, or functions like speak that won't disable the back button.
3.Nothing malicious. Lets keep it fun.

Thanks in advance your creativity and ideas! This should be a blast!
 

mole999

Moderator
Joined
Oct 23, 2004
Messages
9,899
have a read round the lounge, there is at least one thread there that has all these outlandish ideas explored
 

dispelthemyth

Well-known Member
Joined
Mar 16, 2006
Messages
638
How about a random event (occurs between 1 and 10% of the time) that randomly opens up one of their recent pages from the internet or a recently closed file
 

mole999

Moderator
Joined
Oct 23, 2004
Messages
9,899
RAND is in there, not sure about spurious file openings though
 

dispelthemyth

Well-known Member
Joined
Mar 16, 2006
Messages
638
Just checked and all the recent files are stored in memory, the below is a file i put together that see some of your recent files and then
randomly opens and makes active the file you open

https://www.dropbox.com/s/frogev7hjgm6zwn/AprilFools.xlsm



Code i have used is below adapted from another macro i access the registry for

Code:
Sub RandomFileOpen()


Const HKEY_CURRENT_USER = &H80000001
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7


On Error GoTo ErrorHandler


strComputer = "."
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
 strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Office\12.0\Excel\File MRU\"
objReg.EnumValues HKEY_CURRENT_USER, strKeyPath, arrEntryNames, arrValueTypes


For i = 0 To UBound(arrEntryNames)


ReDim StaticArray(0 To UBound(arrEntryNames)) As Variant


 Select Case arrValueTypes(i)
 Case REG_SZ
 objReg.GetStringValue HKEY_CURRENT_USER, strKeyPath, arrEntryNames(i), strvalue
 
 StaticArray(i) = Mid(strvalue, InStr(1, strvalue, "*") + 1, Len(strvalue) - InStr(1, strvalue, "*"))


 End Select
Next
i = Int((UBound(arrEntryNames) - 1 + 1) * Rnd + 1)
R = StaticArray(i)


Workbooks.Open (R)
FName = Mid(R, InStrRev(R, "\") + 1, 999)


Workbooks(FName).Activate
Exit Sub


ErrorHandler:




End Sub



RAND is in there, not sure about spurious file openings though
 
Last edited:

dispelthemyth

Well-known Member
Joined
Mar 16, 2006
Messages
638
Also it will probably only work for Excel 2007 atm as the below code needs to be updated


Code:
strKeyPath = "Software\Microsoft\Office\12.0\Excel\File MRU\"
</pre>
 

mfexcel

Well-known Member
Joined
Jan 8, 2009
Messages
791
I have a non-vba one... and kinda of manual...
go to the PC of your colleagues, press CTRL ALT ↓ (up arrow key)
 

Forum statistics

Threads
1,081,726
Messages
5,360,903
Members
400,602
Latest member
newaqua

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top