The Anchorage
Personal website of Gregory K. Maxey, Commander USN (Retired)
The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.
However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.
If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!
This is just a short novelty Microsoft Word Tips & Microsoft Word Help page to show you how you can use a Windows API and play a short sound byte when a Word document is opened.
Copy and paste the following code to a standard module in the document VB project:
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 provided in this Microsoft Word Help & Microsoft Word Tips page.
That's it! I hope you have found this tips page useful and informative.
The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.
However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.
If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!