Over the Thanksgiving holiday, I was ignoring the family and puttering around on the internet. There, I found a list of all the cool API calls you can do through VBA. An API call is essentially a piece of code you can use to make the Windows operating system do things – like open a directory, freeze the system, open a dialog box, etc.
.
Well, there is an API Call that essentially opens your CD Rom drive. That's right – you can implement code so you don't have to go through the painstaking task of pressing the Open button for your CD Rom drive. Wow …. AUTOMATION IS THE BEST!
.
OK…this gets my vote for the most useless API call. Second place is the API call to close the CD Rom Drive.
.
That being said, you could use this useless API to prank your coworkers.
The trick is to implement the Open CD Rom API call so that every time they open Excel, the CD Rom pops so life. Definitely good for weeks of annoyance and confusion.
.
Step 1:
Go to their computer and navigate to the Visual Basic Editor in Excel and find their Personal Macro Workbook.
.
Step2:
In a new module, copy and paste this code:
-
#If VBA7 Then
-
Declare PtrSafe Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
-
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
-
ByVal uReturnLength As Long, ByVal hwndCallback As LongPtr) As Long
-
#Else
-
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
-
(ByVal lpCommandString As String, ByVal lpReturnString As String, _
-
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
-
#End If
.
.
Step3:
In the Workbook Open Event, copy and paste this code:
-
Private Sub Workbook_Open()
-
Dim retval As Long
-
retval = mciSendString("set CDAudio door open", "", 0, 0)
-
End Sub
.
.
.
Step4:
Save the changes to the Personal Macro Workbook and close Excel.
.
The Evil deed has been done. Every time Excel is opened, the CD Rom drive will pop to life.
Now you can sit back and see how long your victim will live with this crazy opening CD Drive before either fixing it or re-imaging the machine.


This is pure genius. Although, I will just have to send them one of my special spreadsheets with this in the background. Very difficult to get access to someone else's computer in a health insurance company.