View Single Post
  #4   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Playing music in a Word Document

Plan B - if you are creating this as a separate auto-playing
document/template, then change the line

Public Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

to

Private Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Note that the document will not be available for editing until the sound
clip has finished.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Graham Mayor wrote:
I think your job will be safe

See http://www.vbaexpress.com/kb/getarticle.php?kb_id=461

The macro there is similar to the version of it reproduced below,
however this one will play the WAV file indicated on opening the
document
Option Explicit

'API Class to take care of playing the file
Public Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub AutoOpen()
'Call Api to play LoadIt.wav which is in the same folder as
'the active document!
Call sndPlaySound32("C:\Path\Soundfile.WAV", 0)
End Sub

read the linked article which explains how to install the macro.

The macro should ideally be saved in the template of the document (not
normal.dot) - as there are macro security issues involved in saving
it in the document itself, which will could mean that the macro will
not run. Users will of course have to have the template installed in
order to produce the required results.

The sound file must be in WAV format - I tested it with a music track
ripped from a CD and it worked fine. You can either use the full path
to the WAV file as here, or put it in the same folder as the document
and use the path shown in the web page.



Ishmael Goldstein wrote:
I am new to word and after reading through some of the posts here I
realize most of the MVPs don't have Word 2000 installed anymore but
maybe someone can still help me out.
My current supervisor has assigned me a task to create for him a word
document with text, pictures and music playing upon opening the file.
The latest version of office installed on our work PCs is 2000 and I
do not have any version on my home PC. I have managed to create
everything except the song he wants to play and finally exhausted all
my resources. I did manage to go to the toolbar, Insert; Objects;
create from file, and inserted the sound file (wav format) into my
document. But that's as far as my knowledge goes and I don't know how
to make it play when you open the word document. I know it's in there
somewhere because when I click on edit the drop down box has a sound
recorder document object there but going through those options has
not helped me out and I'm stumped. Is this even possible? My
employer seems to be convinced it is and wont take 'I have no idea'
for an answer. My job may be on the line.......can anyone help me
with this?
Thank you,