PlaySound issue with Windows 7 64 bit

MikeBillsFan

New Member
Joined
Jul 29, 2010
Messages
7
I have a popular fantasy football spreadsheet package which I've sold for years. One of the features (frills) in one of the files is the ability to play "trash talking" sound effects. Someone in your fantasy draft makes a pick you want to laugh at, click the appropriate sound file, and hit play. Not a necessary feature of course but a lot of people like it.

Anyway, I've had a couple customers tell me the file won't open at all - throws an error - on their system with Windows 7 64-bit. The error is coming from the countdown timer and sound module.

Since it isn't opening at all, I believe it is coming from the opening section of the code, as follows:

Code:
Option Explicit
Public RunWhen As Double
Public TimeStart As Double
Public blnFirst  As Boolean
Public Const cRunIntervalSeconds = 1    ' 1 second
Public Const cRunWhat = "The_Sub"
Public bookName As String
Public sTotalTime As Date
Private Declare Function PlaySound Lib "winmm.dll" _
  Alias "PlaySoundA" (ByVal lpszName As String, _
  ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Const SND_MEMORY = &H4
Const SND_PURGE = &H40 'purge the sound

Since this is mostly related to playing the sounds, I've narrowed my search to that. At this point I'm at a loss though. Can someone help me get this running in all versions of Windows?

For those current Win7 64x users, I've taken out this module and now they are fine (but these features don't work). Obviously I'd like a solution that works across all platforms so I don't have to roll out different file versions.

Thanks in advance for any advice!
 
I tried this as a workaround. My problem is now solved.

Code:
Call Shell("C:\Program Files (x86)\Windows Media Player\wmplayer.exe C:\sound\soundfile.wav", 0)
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I came across this thread today via Google and have very little recollection of the conversation back then. Two years later, I'm still selling my fantasy football spreadsheet, but I removed the sound features for 64-bit users in 2010 (made separate file available for download), and I removed sound features for all users in 2011 (for other reasons).

After a lot of feedback from 2011 about where the sound features went, I want to put them back for 2012. Goal is to make them work for all versions of Windows and Mac.

I think I have my Mac solution, as outlined here:

http://www.draftbuddy.com/2012/05/22/playing-sound-files-in-mac-excel-finally-solved/

Now I want to ensure it works on all versions of Windows, and I'm still stumped about 64-bit versions of Excel and Windows.

I have Windows 7 using Excel 2007 and Excel 2003. Can someone please confirm for me the following works on Excel 2010 64-bit (and other combinations, if you don't think it will)?

Code:
Option Explicit
Public RunWhen As Double
Public TimeStart As Double
Public blnFirst  As Boolean
Public Const cRunIntervalSeconds = 1    ' 1 second
Public Const cRunWhat = "The_Sub"
Public bookName As String
Public sTotalTime As Date
 
#If VBA7 Then
Private Declare PtrSafe Function PlaySound Lib "winmm.dll" _
  Alias "PlaySoundA" (ByVal lpszName As String, _
  ByVal hModule As LongPtr, ByVal dwFlags As Long) As Long
#Else
Private Declare Function PlaySound Lib "winmm.dll" _
  Alias "PlaySoundA" (ByVal lpszName As String, _
  ByVal hModule As Long, ByVal dwFlags As Long) As Long
#End If
 
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Const SND_MEMORY = &H4
Const SND_PURGE = &H40 'purge the sound
 
Sub PlayWAV(WAVFile)
    Dim WAVFile As String
    WAVFile = "jeopardy.wav"
    If Application.OperatingSystem Like "Mac*" Then
        If MsgBox("Unfortunately, Draft Buddy cannot play sounds on a Mac operating system at this time.", vbOK, "Unable to Play Sound File") = vbOK Then
        End If
        Exit Sub
    Else ' Application.OperatingSystem Like "Win*" Then
        WAVFile = ThisWorkbook.Path & "\sounds\" & WAVFile
        Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
    End If
End Sub

Hardcode whatever .wav file you like that you have available where I have "jeopardy.wav".

I haven't integrated the Mac solution yet which is why that code isn't in there.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top