adding sound with vba for blind friend

J

Jay Edgar

Hi all:

A friend of mine is developing his career as a public speaker (read: he has
no money). I'm developing code that will read the slide number every time he
moves to a new slide.

I'm a VBA wiz with Access, yet completely lost with PPT. I found some code
that will display a message box with each slide change (Sub Auto_NextSlide).
I need to play a .wav, .mp3, etc., instead. Can anyone tell me the command?

Your help is greatly appreciated.

Regards,

Jay
 
J

Jay Edgar

Thank you, Shyam. I looked through your site last night, and appreciate your
help. I will give this a shot tonight or tomorrow.

Regards,

Jay
 
J

Jay Edgar

Shyam:

I'm a bit flummoxed, so will ask your help once again.

I used the code on the page to which you referred me. I discovered it didn't
work with mp3s (just thought I'd try), and got it to work for a wav file. I
placed the code to play the wav in the next slide event. It worked great.

Next I added a for loop like:

for i = 1 to Index
[code to play the sound]
next i

thinking it would play the tone as many times as the number of the slide. It
didn't work. When I set to code back to what worked, it no longer worked. I
then deleted both the PPT and PPA, and brought out the original versions
from the zip file. No go. I removed and readded the add-in. No go. I
restarted my computer. No go. The security is low security and both 'trust'
checkboxes are turned on. Any clue how I fix it?

Thank you for your help.

Regards,

Jay

P.S. Computers drive me nuts sometimes. Good thing I always win in the
end...
 
J

Jay Edgar

I did some more experimentation. I put debug.print statements in each of the
events (starting, closing, opening, etc.).

None of the events is kicked off when I open or run a presentation.

In the code window, if I have the cursor in any event and hit F5, it runs
the event (displays the message box and does the debug.print) EXCEPT the
next slide event. when I have the cursor in this event and hit F5, it brings
up a dialog box with all events and asks which one I want to run. The next
slide event is not listed, as though the code can't see it. huh? The modules
debug just fine.

I have never seen anything like this in all my years of Access VBA work. The
only thing I can think is to dump Office and reload, which I'd REALLY rather
not do. I will also try this on my computer at work.

Again, any help is appreciated.

Regards,

Jay
 
S

Shyam Pillai

Jay,
for i = 1 to Index
[code to play the sound]
next i

Running the code in the loop will fail, the playback returns control
immediately

To playback an mp3 file, you can use the following code:
' Declarations
Declare Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" ( _
ByVal lpstrCommand As
String, _
ByVal
lpstrReturnString As Any, _
ByVal uReturnLength
As Long, _
ByVal hwndCallback As
Long) As Long

Sub PlaybackMP3UsingMCI()

Dim I as Long
Dim sFilename as String

I = mciSendString("open " & chr(34) & sFilename & chr(34) & " type MPEGVideo
alias Narration", 0&, 0, 0)
I = mciSendString("play Narration", 0&, 0, 0)

End Sub

Sub StopPlayback
Dim I as Long
I = mciSendString("stop Narration", 0&, 0, 0)
I = mciSendString("close Narration", 0&, 0, 0)

End Sub


--
Regards,
Shyam Pillai

Animation Carbon: http://skp.mvps.org/ac/



Jay Edgar said:
Shyam:

I'm a bit flummoxed, so will ask your help once again.

I used the code on the page to which you referred me. I discovered it
didn't work with mp3s (just thought I'd try), and got it to work for a wav
file. I placed the code to play the wav in the next slide event. It worked
great.

Next I added a for loop like:
for i = 1 to Index
[code to play the sound]
next i

thinking it would play the tone as many times as the number of the slide.
It didn't work. When I set to code back to what worked, it no longer
worked. I then deleted both the PPT and PPA, and brought out the original
versions from the zip file. No go. I removed and readded the add-in. No
go. I restarted my computer. No go. The security is low security and both
'trust' checkboxes are turned on. Any clue how I fix it?

Thank you for your help.

Regards,

Jay

P.S. Computers drive me nuts sometimes. Good thing I always win in the
end...
 
Top