How to program Excel 2010 Win7 64bit to play audio waves in response to changing variables

phinsdale

New Member
Joined
Apr 28, 2014
Messages
5
Operating environment: Windows 7 64 bit running Excel 2010.

My present application processes streaming data and generates constantly changing visual interpretations. Now I want to make the application talk to me in English.

My plan: 1. Record a variety of alert messages and action commands as WAV files. 2. Create a new spreadsheet with a separate range related to each contemplated wav message. 3. Test the values in the ranges against a standard. 4. If a hit, use VBA to play the recorded message. It needs to be very fast to keep up with the streaming data.

Problem: I thought I knew how to write the desired program, but apparently Win 7 64bit has disabled the old VBA commands.

I have Mr. Jelen's book VBA and Macros on my Kindle. From that I decided to join this forum.

I know that this subject was addressed when Win 7 64bit was new. My application is not commercial and it does not need to be backward compatible. Thank in advance for the boost that will put me over the hurdle. Palmer Hinsdale
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,692
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
Are you using 64bit Office as well as 64bit Windows?

What VBA commands are you having an issue with exactly?
 

phinsdale

New Member
Joined
Apr 28, 2014
Messages
5
Are you using 64bit Office as well as 64bit Windows?

What VBA commands are you having an issue with exactly?

Rory, Thank you for your response.
Yes I am using 64bit Office.
I was trying to use Play Sound which I had learned some years ago.
I think my problem is that really do not understand the API environment as distinct from Excel and VBA.
Thanks, Palmer.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,692
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
Can you post the code you were using? You often just need to change the API declarations to use Declare PtrSafe rather than just Declare, unless the code uses window handles.
 

phinsdale

New Member
Joined
Apr 28, 2014
Messages
5
Thank you. I need to break off now for remainder of the day here in San Francisco. Palmer.
 

phinsdale

New Member
Joined
Apr 28, 2014
Messages
5
Rory--I have done some additional work, but I am still failing.

Changed info: my system is running Excel 2010 (32 bit) Office 2010 (32 bit) under Windows 7 with a 64 bit processor.

Here is the code which fails. Obtained from Mr. Jelen's book "VBA and Macros"

Option Explicit
Option Base 1


Public Declare Function PlayWavSound _
Lib "winmm.dll" _
Alias "sndPlaySoundA" _
(ByVal LpszSoundName As String, _
ByVal uFlags As Long) As Long


Public Sub Playsound()
Dim SoundName As String


SoundName = "C:Windows\Media\Tada.wav"
PlayWavSound SoundName, 0

End Sub

BTW, I want the sound to be played with ASYNC so that it does not stop the flow of my primary program. The snippet above is just a test on my laptop.

Thanks. Palmer
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,692
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
You appear to be missing a backslash here:
Rich (BB code):
SoundName = "C:\Windows\Media\Tada.wav"
 

phinsdale

New Member
Joined
Apr 28, 2014
Messages
5
Thank that fixed it with sounds which are part of Windows. Not working with my recorded voice. Now I realize that Microsoft changed the file type for recording to WMA. So, I guess my next step is to learn how to record WAV. Thanks. Palmer.
 

Watch MrExcel Video

Forum statistics

Threads
1,089,902
Messages
5,411,120
Members
403,342
Latest member
faizanhamied

This Week's Hot Topics

Top