Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The Public declare function for the mciExecute is at the top of the module as
is the other Public declare function which I use for .wav files. The sub that turns the midi file on and off is titled PlayMidiFile. The last sub is the one that calls the PlayMidiFile during normal code execution. I have stepped through the code and it is finding the midi file and is telling it to execute. The problem is that there is no sound. I have to assume that it does not execute. There have been several automatic downloads to my system lately and I have no idea what they might have affected, but this code was working perfectly until I tried it today. I can play the midi file using the Windows Media Player, so the midi file is not corrupt. Does anybody have a clue? It has me snowed. Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _ (ByVal lpszName As String, hModule As Long, ByVal dwFlags _ As Long) As Long Public Declare Function mciExecute Lib "winmm.dll" _ (ByVal lpstrCommand As String) As Long Sub PlayMidiFile(MidiFileName As String, Play As Boolean) 'Function for calling midi files If Dir(MidiFileName) = "" Then Exit Sub ' no file to play If Play Then mciExecute "play " & MidiFileName ' start playing Else mciExecute "stop " & MidiFileName ' stop playing End If End Sub Sub x() MidiStr = "" On Error Resume Next MidiStr = Dir("c:\windows\media\*.mid") On Error GoTo 0 If MidiStr < "" Then Set fs = Application.FileSearch With fs .LookIn = "C:\Windows\Media" .Filename = "*.mid" If .Execute 0 Then MySnd = .FoundFiles(1) End If End With PlayMidiFile (MySnd), True End If End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Have you tried playing the file with media player or similar? (To make sure
the sound isn't set to mute or the volumn is turned down.) -- Regards, Tom Ogilvy "JLGWhiz" wrote: The Public declare function for the mciExecute is at the top of the module as is the other Public declare function which I use for .wav files. The sub that turns the midi file on and off is titled PlayMidiFile. The last sub is the one that calls the PlayMidiFile during normal code execution. I have stepped through the code and it is finding the midi file and is telling it to execute. The problem is that there is no sound. I have to assume that it does not execute. There have been several automatic downloads to my system lately and I have no idea what they might have affected, but this code was working perfectly until I tried it today. I can play the midi file using the Windows Media Player, so the midi file is not corrupt. Does anybody have a clue? It has me snowed. Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _ (ByVal lpszName As String, hModule As Long, ByVal dwFlags _ As Long) As Long Public Declare Function mciExecute Lib "winmm.dll" _ (ByVal lpstrCommand As String) As Long Sub PlayMidiFile(MidiFileName As String, Play As Boolean) 'Function for calling midi files If Dir(MidiFileName) = "" Then Exit Sub ' no file to play If Play Then mciExecute "play " & MidiFileName ' start playing Else mciExecute "stop " & MidiFileName ' stop playing End If End Sub Sub x() MidiStr = "" On Error Resume Next MidiStr = Dir("c:\windows\media\*.mid") On Error GoTo 0 If MidiStr < "" Then Set fs = Application.FileSearch With fs .LookIn = "C:\Windows\Media" .Filename = "*.mid" If .Execute 0 Then MySnd = .FoundFiles(1) End If End With PlayMidiFile (MySnd), True End If End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That is what is so confusing. The file plays ok on the media player, so the
only thing I could surmise was that, although it indicates that it is initiating the execute command to play, in is not in fact executing. I was just reviewing some of the recent automatic updates and can't see anything that would directly affect the internal code execution. Most of the updates were related to blocking external hackers into Windows system files. Oh, well. Maybe somebody smarter than me will have the same problem and figure it out. It is not in a critical system, but I like to have things work after I spend a lot of time putting them together. "Tom Ogilvy" wrote: Have you tried playing the file with media player or similar? (To make sure the sound isn't set to mute or the volumn is turned down.) -- Regards, Tom Ogilvy "JLGWhiz" wrote: The Public declare function for the mciExecute is at the top of the module as is the other Public declare function which I use for .wav files. The sub that turns the midi file on and off is titled PlayMidiFile. The last sub is the one that calls the PlayMidiFile during normal code execution. I have stepped through the code and it is finding the midi file and is telling it to execute. The problem is that there is no sound. I have to assume that it does not execute. There have been several automatic downloads to my system lately and I have no idea what they might have affected, but this code was working perfectly until I tried it today. I can play the midi file using the Windows Media Player, so the midi file is not corrupt. Does anybody have a clue? It has me snowed. Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _ (ByVal lpszName As String, hModule As Long, ByVal dwFlags _ As Long) As Long Public Declare Function mciExecute Lib "winmm.dll" _ (ByVal lpstrCommand As String) As Long Sub PlayMidiFile(MidiFileName As String, Play As Boolean) 'Function for calling midi files If Dir(MidiFileName) = "" Then Exit Sub ' no file to play If Play Then mciExecute "play " & MidiFileName ' start playing Else mciExecute "stop " & MidiFileName ' stop playing End If End Sub Sub x() MidiStr = "" On Error Resume Next MidiStr = Dir("c:\windows\media\*.mid") On Error GoTo 0 If MidiStr < "" Then Set fs = Application.FileSearch With fs .LookIn = "C:\Windows\Media" .Filename = "*.mid" If .Execute 0 Then MySnd = .FoundFiles(1) End If End With PlayMidiFile (MySnd), True End If End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Checking the return value of the API call may give you an better idea of the
error. But I see you are not using PlaySound, which is the easiest way. NickHK "JLGWhiz" wrote in message ... The Public declare function for the mciExecute is at the top of the module as is the other Public declare function which I use for .wav files. The sub that turns the midi file on and off is titled PlayMidiFile. The last sub is the one that calls the PlayMidiFile during normal code execution. I have stepped through the code and it is finding the midi file and is telling it to execute. The problem is that there is no sound. I have to assume that it does not execute. There have been several automatic downloads to my system lately and I have no idea what they might have affected, but this code was working perfectly until I tried it today. I can play the midi file using the Windows Media Player, so the midi file is not corrupt. Does anybody have a clue? It has me snowed. Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _ (ByVal lpszName As String, hModule As Long, ByVal dwFlags _ As Long) As Long Public Declare Function mciExecute Lib "winmm.dll" _ (ByVal lpstrCommand As String) As Long Sub PlayMidiFile(MidiFileName As String, Play As Boolean) 'Function for calling midi files If Dir(MidiFileName) = "" Then Exit Sub ' no file to play If Play Then mciExecute "play " & MidiFileName ' start playing Else mciExecute "stop " & MidiFileName ' stop playing End If End Sub Sub x() MidiStr = "" On Error Resume Next MidiStr = Dir("c:\windows\media\*.mid") On Error GoTo 0 If MidiStr < "" Then Set fs = Application.FileSearch With fs .LookIn = "C:\Windows\Media" .Filename = "*.mid" If .Execute 0 Then MySnd = .FoundFiles(1) End If End With PlayMidiFile (MySnd), True End If End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Nick, if I add PlaySound to the mci function, it throws a critical error.
It was working fine without it for several months. This anomally just popped up here in the last couple of weeks. Don't know the exact time it formed because I don't run the program that much. I was just doing some file maintenance and ran that program to see if it needed tweaking and sure enough, it needed something. I can't help but believe this problem is a result of some automatic security downloads. Stepping through the code indicates that it should be playing. "NickHK" wrote: Checking the return value of the API call may give you an better idea of the error. But I see you are not using PlaySound, which is the easiest way. NickHK "JLGWhiz" wrote in message ... The Public declare function for the mciExecute is at the top of the module as is the other Public declare function which I use for .wav files. The sub that turns the midi file on and off is titled PlayMidiFile. The last sub is the one that calls the PlayMidiFile during normal code execution. I have stepped through the code and it is finding the midi file and is telling it to execute. The problem is that there is no sound. I have to assume that it does not execute. There have been several automatic downloads to my system lately and I have no idea what they might have affected, but this code was working perfectly until I tried it today. I can play the midi file using the Windows Media Player, so the midi file is not corrupt. Does anybody have a clue? It has me snowed. Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _ (ByVal lpszName As String, hModule As Long, ByVal dwFlags _ As Long) As Long Public Declare Function mciExecute Lib "winmm.dll" _ (ByVal lpstrCommand As String) As Long Sub PlayMidiFile(MidiFileName As String, Play As Boolean) 'Function for calling midi files If Dir(MidiFileName) = "" Then Exit Sub ' no file to play If Play Then mciExecute "play " & MidiFileName ' start playing Else mciExecute "stop " & MidiFileName ' stop playing End If End Sub Sub x() MidiStr = "" On Error Resume Next MidiStr = Dir("c:\windows\media\*.mid") On Error GoTo 0 If MidiStr < "" Then Set fs = Application.FileSearch With fs .LookIn = "C:\Windows\Media" .Filename = "*.mid" If .Execute 0 Then MySnd = .FoundFiles(1) End If End With PlayMidiFile (MySnd), True End If End Sub |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How are you calling PlaySound.
Exanple from API-Guide: Private Const SND_ASYNC = &H1 ' play asynchronously Private Const SND_FILENAME = &H20000 ' name is a file name Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long Private Sub Form_Load() PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC End Sub NickHK "JLGWhiz" wrote in message ... Hi Nick, if I add PlaySound to the mci function, it throws a critical error. It was working fine without it for several months. This anomally just popped up here in the last couple of weeks. Don't know the exact time it formed because I don't run the program that much. I was just doing some file maintenance and ran that program to see if it needed tweaking and sure enough, it needed something. I can't help but believe this problem is a result of some automatic security downloads. Stepping through the code indicates that it should be playing. "NickHK" wrote: Checking the return value of the API call may give you an better idea of the error. But I see you are not using PlaySound, which is the easiest way. NickHK "JLGWhiz" wrote in message ... The Public declare function for the mciExecute is at the top of the module as is the other Public declare function which I use for .wav files. The sub that turns the midi file on and off is titled PlayMidiFile. The last sub is the one that calls the PlayMidiFile during normal code execution. I have stepped through the code and it is finding the midi file and is telling it to execute. The problem is that there is no sound. I have to assume that it does not execute. There have been several automatic downloads to my system lately and I have no idea what they might have affected, but this code was working perfectly until I tried it today. I can play the midi file using the Windows Media Player, so the midi file is not corrupt. Does anybody have a clue? It has me snowed. Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _ (ByVal lpszName As String, hModule As Long, ByVal dwFlags _ As Long) As Long Public Declare Function mciExecute Lib "winmm.dll" _ (ByVal lpstrCommand As String) As Long Sub PlayMidiFile(MidiFileName As String, Play As Boolean) 'Function for calling midi files If Dir(MidiFileName) = "" Then Exit Sub ' no file to play If Play Then mciExecute "play " & MidiFileName ' start playing Else mciExecute "stop " & MidiFileName ' stop playing End If End Sub Sub x() MidiStr = "" On Error Resume Next MidiStr = Dir("c:\windows\media\*.mid") On Error GoTo 0 If MidiStr < "" Then Set fs = Application.FileSearch With fs .LookIn = "C:\Windows\Media" .Filename = "*.mid" If .Execute 0 Then MySnd = .FoundFiles(1) End If End With PlayMidiFile (MySnd), True End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sound with excel | Excel Discussion (Misc queries) | |||
Sound on Excel | Excel Discussion (Misc queries) | |||
Display Text and Play Sound file | Excel Programming | |||
Display Text and Play Sound file | Excel Programming | |||
playing sound??? | Excel Programming |