?
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
?
804 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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…

777 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