View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lulu Lulu is offline
external usenet poster
 
Posts: 18
Default Close the other application

For the life of me, I cannot remember how to get the application I've called
with Shell function to close.

Here's my code:

Private Sub lstElves_Click()
Dim person As String, naughty As Integer, santasez As String
person = Me!lstElves.Column(0) 'user picks name on list
naughty = Int(Rnd() * 100) 'random value generated

'determines naughty and nice
If naughty Mod 2 = 0 Then
santasez = "You've Been " & vbCrLf & "Very Nice!"
MakeSound = Shell("C:\Program Files\Windows Media Player\wmplayer.exe
c:\xmas\hohoho.wav", 0)
Else
santasez = "You've Been " & vbCrLf & "Very Naughty!"
MakeSound = Shell("C:\Program Files\Windows Media Player\wmplayer.exe
c:\xmas\humbug.wav", 0)
End If

'displays personalized message while Hohoho or Humbug is playing in background
Me!lblSez = person & ", " & vbCrLf & "Santa Says " & santasez
End Sub

problem is wmplayer needs to close at end of each cycle, else wmplayer
becomes visible the second time through

All this is through an Excel form. Having brain-block. So far anything
I've tried closes the Excel form, not the wmplayer application.

Many thanks.