Microsoft KB Archive/89316

{|
 * width="100%"|

WD: How to Play a .wav Sound File from Word for Windows

 * }

Q89316

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows, versions 7.0, 7.0a

-

SUMMARY
The &quot;More Information&quot; section of this article includes an example of a macro you can use to play a .wav sound file.

MORE INFORMATION
NOTE: Microsoft provides macros &quot;as is&quot; without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Word for Windows 95, version 7.x
'These declarations must be on one line. 'Place them above the Sub Main.

Declare Function sndPlaySoundA Lib &quot;winmm&quot; \ (lpszSoundName$, wFlags As Long) As Long Declare Function GetWindowsDirectoryA Lib \ &quot;Kernel32&quot;(WinDir$, nSize As Long) As Long

Sub MAIN Windir$ = String$(255, &quot;X&quot;) N = GetWindowsDirectoryA(WinDir$, 255) N = sndPlaySoundA(WinDir$ + &quot;\tada.wav&quot;, 0) End Sub

Using Microsoft Windows version 3.1
     '** Calling dynamic-link libraries** Declare Function sndPlaySound Lib &quot;mmsystem.dll&quot; \ (lpszSoundName$, wFlags As Integer) As Integer Declare Function GetWindowsDirectory Lib \ &quot;Kernel&quot;(WinDir$, nSize As Integer) As Integer

Sub MAIN '*Create a variable large enough to store the Windows path. Windir$ = String$(255, &quot;X&quot;) '*Store the path to the Windows directory in WinDir$ variable. N = GetWindowsDirectory(WinDir$, 255) '*Load and Play the sound. N = sndPlaySound(WinDir$ + &quot;\tada.wav&quot;, 0) End Sub NOTE: This macro assumes that your computer has a sound driver and does not check if the driver is loaded.

For more complete information about the sndPlaySound function of the MMSYSTEM.DLL, refer to the &quot;Multimedia Programmer's Reference.&quot; This manual is part of the Microsoft Windows operating system version 3.1 Software Development Kit (SDK).

Additional query words: winapi mpc multimedia multi- media personal pc word7 word6

Keywords : kbmacro kbusage kbmacroexample winword word6 winword2 word7 word95

Issue type :

Technology :