View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Steve Yandl[_3_] Steve Yandl[_3_] is offline
external usenet poster
 
Posts: 117
Default Practical Jokes in Excel?

This trick is benign but don't use it on your friend if he is prone to
panic. The sub is located in a worksheet rather than a module and the
trigger is selection of cell C2 (event was an arbitrary choice on my part).
There is a quick text to speech deployed to tell the user that selecting the
cell was a bad thing. Then an hta file (HTML application file) is created
in the temp folder and launched. This hta file doesn't do anything (no
script) but it's designed to open maximized with no caption and no scroll
bar. The effect of running the hta file is that the entire screen is filled
with whatever the normal background color for windows is (white in most
cases). The cursor will appear and can be moved but clicking the mouse or
attempting to type does nothing. The escape is the 'Alt + F4' combination
to close the active window and the user will be returned to the Excel sheet.
A Windows savvy user may also use Ctrl + Alt + del to get the task list,
locate mshta.exe and kill the process which has the same effect as Alt + F4.

'________________________________

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim strNotify As String

strNotify = "Selecting this cell was a bad thing"

If Target.Address = "$C$2" Then
Application.EnableEvents = False
Set objVoice = CreateObject("SAPI.SpVoice")
objVoice.Speak strNotify
Set fso = CreateObject("Scripting.FileSystemObject")
strHTAname = fso.GetSpecialFolder(2) & "\Temp000.hta"
Set txtHTA = fso.CreateTextFile(strHTAname)
With txtHTA
.WriteLine "<HTML"
.WriteLine "<HTA:Application"
.WriteLine "Caption=" & Chr(34) & "no" & Chr(34)
.WriteLine "WindowState=" & Chr(34) & "Maximize" & Chr(34)
.WriteLine "Scroll=" & Chr(34) & "no" & Chr(34) & ""
.WriteLine "</HTML"
End With
Shell ("mshta.exe " & Chr(34) & strHTAname & Chr(34))
Set fso = Nothing
Set objVoice = Nothing
Application.EnableEvents = True
End If

End Sub

'________________________________



"Ray" wrote in message
...
Hello -

What practical jokes have you played with Excel, either VBA or just
built-in features? With all of the creativity on this Board, I figure
there's got to be quite a few gems out there ...

One of my coworkers thinks he knows it all, so I'd like to punk
him ... my initial thought was a macro that would speak something
(using text-to-speech) or play a sound when a specific key is pressed
(say, the SHIFT or CTRL keys). I have absolutely no idea where to
start with this ... thoughts?

Looking forward to seeing what's been done before!

//ray