Close the other application

L

Lulu

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.
 
S

Stephen Knapp

As I recall the SHELL function, you hand it the executable and
parameters, followed by the "verb" that the application is to perform. In
this case, you handed the WMPlayer a verb of 0 (zero). I'm guessing that
this makes it play. You'll need to find the verb that closes the instance of
the WMPlayer after each tune is finished. I haven't played with the SHELL
command for a long time so I can only suggest that you do more homework (if
you haven't done so already).

Steve in Ohio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top