Play Sound File in User Form

R

Robin

I am using Word 2003, SP2.

I have created a template with a customized toolbar. From this toolbar, the
user can open a user form where they can select other options from command
buttons.

For humor sake, I'd like to play a sound file when the form is open. I
figured out how, but want to embed the sound file so that it travels with the
document. Right now, the sound file plays from a location on our server.

Is there a way to do this?
 
H

Helmut Weber

Hi Robin,

put e.g. an unlinked wave-object into your doc.
Hide it somewhere and somehow.
You may protect it by adding a protected form,
maybe at the end of the doc, which contains nothing
but the invisible shape or inlineshape.

Which may work or may not work, depending on your users.

Ok, if for humor's sake:

Sub play()
Dim oShp As Shape
For Each oShp In ActiveDocument.Shapes
oShp.Select ' for testing remove later
If oShp.Type = msoEmbeddedOLEObject Then
oShp.OLEFormat.Activate
End If
Next
End Sub

Just to show the principle.
There is, IMHO, a lot of error handling missing.
You might check the oShp.OLEFormat.ClassType as well,
which should be "SoundRec".

Have some fun.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top