Solved

How can I embed a simple sound file into an Excel application and play it using VBA?

Posted on 2006-07-11
14
785 Views
Last Modified: 2012-05-05
Hi all,

How can I embed a simple sound file into an Excel application and play it using VBA?

thanks

Avi
0
Comment
Question by:progtw
  • 5
  • 3
  • 3
  • +1
14 Comments
 

Author Comment

by:progtw
ID: 17084074
Hi all again,

Sorry. I meant to ask:

How can I embed a simple sound file into an Excel *sheet* and then play it using VBA (e.g., when somebody opens the sheet)?

thanks

Avi
0
 
LVL 44

Expert Comment

by:bruintje
ID: 17084195
Hi progtw,
----------

not sure but i don't think you can embed a sound file into Excel, maybe a flash animation but not something like a wav

you can play it through VBA
http://www.exceltip.com/st/Playing_WAV-files_using_VBA_in_Microsoft_Excel/460.html

and call the sub through the Workbook_Open event
http://www.ozgrid.com/VBA/auto-run-macros.htm

----------
bruintje
0
 

Author Comment

by:progtw
ID: 17088351
Thanks. I will get back to you , one I have tried it out.

avi
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:progtw
ID: 17098174
>> not sure but i don't think you can embed a sound file into Excel
Yes you can. I did it.

avi
0
 
LVL 44

Expert Comment

by:bruintje
ID: 17106340
great how did you do it?
0
 

Author Comment

by:progtw
ID: 17108151
Simple. I just did:

1. Click the Insert menu.

2. Select the Object command.

3. Click the Browse tab.

4. Look for your file, e.g. a WAV file.

5. Double click.
   Object is inserted on current cell.

6. Right click on object. And select the Run or Activate command.

Do I get points?

avi


0
 
LVL 44

Expert Comment

by:bruintje
ID: 17108195
you can get a refund by asking a 0 point question with a link to this one here
http://www.experts-exchange.com/Community_Support/

and you have the good feeling of helping future requests for this same situation :-)
0
 
LVL 8

Expert Comment

by:stochastic
ID: 17114168
avi,

If I understand the interaction correctly, you know how to insert a sound object into Excel.
But that still doesn't answer your question about how to play it when the workbook is opened.
Is that correct?

SoundNote objects were removed from the Excel object model after XL97. However you can still
make a API call to play an external sound file (not one that's embedded).

See http://www.j-walk.com/ss/excel/tips/tip59.htm (thanks to John Walkenback)

To auto-play it on opening worksheet is a simple additional step:
insert that code into
Private Sub Workbook_Open()
   
in your workbook code. (If you need help on how to do that, please ask).

cheers - stochastic
0
 

Author Comment

by:progtw
ID: 17144822
>> SoundNote objects were removed from the Excel object model after XL97
Dumb question - Why were SoundNote objects were removed from the Excel object model after XL97

(We are supposed to be geeting more sophisticated. So why are features being taken out...?)

>> However you can still make a API call to play an external sound file (not one that's embedded).
Not good enough. I wanted to send a file through email and make it sing when the recipient opens it...

avi

0
 
LVL 8

Expert Comment

by:stochastic
ID: 17145092
>> Dumb question - Why were SoundNote objects were removed from the Excel object model after XL97
I really don't know. Perhaps bruintje will tell us.

But there _is_ a way. By doing Insert->Object->From File, you can insert a sound object (say from a wav file).

And you can actually play that object on file open by putting the following code in workbook_open event.

Private Sub Workbook_Open()
    ActiveSheet.Shapes("Object 1").Select
    Selection.Verb Verb:=xlPrimary
End Sub

Mind you - since the file will contain a macro, your user _will_ get a macro warning unless security setting is Low.
And that (macro warning) might spoil the fun if you wanted to surprise the user!

Still, for whatever it is worth ....

If you want a sample file uploaded please let me know.

- sto

0
 
LVL 8

Expert Comment

by:stochastic
ID: 17443933
I think the asker got reasonable answers that fully satisfy
the need, so I don't see a case for a refund. At the very least, not without
the asker explicitly articulating that the answer wasn't good enough, and asking
for a delete / refund.

- stochastic

0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17470220
PAQed with points refunded (125)

DarthMod
Community Support Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question