Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-07-11
14
Medium Priority
?
811 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
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…

927 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