Solved

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

Posted on 2006-07-11
14
776 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will show you how to use shortcut menus in the Access run-time environment.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now