Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Play Sound Clip - Word VBA 2

Status
Not open for further replies.

hahnsm

MIS
Jun 17, 2003
62
0
0
US
I would like to have a sound clip start to play when I open up a certain Word document. What VBA code can I use for this to happen?
 
Thanks PHV but this code doesn't help me out. I would like to have the soundwav start playing when the document is opened and then looped until the document is closed. Can you help me with that code? Thank you so much!
Sadie
 
In a standard code module:
Code:
Public Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

In the ThisDocument class module:
Code:
Const SND_ASYNC = &H1
Const SND_LOOP = &H8

Private Sub Document_Open()
  Dim strWav As String
  strWav = "\path\to\file.wav"
  sndPlaySound strWav, SND_ASYNC Or SND_LOOP
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hmmm, that looks very useful ... will pass on to my Word specialist friends ..... -----> * ( star for that [smile] )


Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top