ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close the other application (https://www.excelbanter.com/excel-programming/317303-close-other-application.html)

Lulu

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.


Stephen Knapp

Close the other application
 
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

"Lulu" wrote:

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.



All times are GMT +1. The time now is 06:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com