Play Sound Byte When Document Opens

Home Up Odds & Ends Photo Gallery Search Contact Me

 

 

The information in this website is provided without risk or obligation and free of charge.  However, if you have benefitted from my efforts here and would like to make a contribution to help me continue and maintain this work then any donation will be greatly appreciated. Please click the adjacent button to access PayPal.  Thank you.
 
This is just a short novelty Microsoft Word Help and Tips Page to show you how you can use an API (Application Programming Interface) to play a sound byte when a Word document is opened.
Copy the following code to project module of the document:
Option Explicit
Private Declare Sub PlaySound Lib "winmm.dll" _
     (ByVal lpszName As String, _
     ByVal hModule As Long, _
    ByVal dwFlags As Long)
Private Const SOUND_FILENAME = &H20000

Sub AutoOpen()
Dim sndFileName As String
'Note:  Change the next line to point to your sound file.
sndFileName = "C:\Sound 1.wav" 
PlaySound sndFileName, 0&, SOUND_FILENAME
End Sub
See:  Installing Macros for instructions on how to set up and use the macros listed above.

Looking for something else?