Personal website of Gregory K. Maxey, Commander USN (Retired)
Do you have ad-blocking software enabled? While I respect your right to do so, your donations and the minimal advertisements on this site help to defray internet and other costs of providing this content. Please consider excluding this website from blocking or turning off the blocker while browsing this site.
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.
Do you want to make a payment for consulting work or donate to help support this site?
PayPal is a safe, easy way to pay online.
Use the appropriate currency "Donate" button to make a payment or donation.