Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Trying to close Excel Application in IE | Excel Discussion (Misc queries) | |||
close excel application. | Excel Programming | |||
macro to close excel application other than application.quit | Excel Programming | |||
Close External Application using VBA | Excel Programming | |||
Application.Close | Excel Programming |