Embedding a resource into VBA addin

tracks

New Member
Joined
Aug 31, 2005
Messages
21
Hi,

Does anyone know if its possible to embed a resource (such as a wav file) into a VBA xla addin?



It's definitely possible in regular VB, but can't seem to find any info on it for VBA.
 
I think youre both right Mitchys and Right_Click about the behavior of this OLE object.

I didn't notice before, but the type of "embed" seems to affect the behavior. For the object to play in background, it must be inserted as a "Sound Recorder Document". If it's inserted as a "Package", then the registered application is opened to handle the document... in my case winamp.

if you check the formula contents of the object, they read the following when the sound object behaves normally (in background):

=EMBED("Sound Recorder Document","")


However, if it reads the following, then the registered app handles the file:
=EMBED("Package","")


When adding an object, the create from file should be able to detect what kind of file it is and assign the appropiate package type. For example, when adding a wave file, it should automatically make it a "Sound Recorder Document".

I think what caused my issue is that for some reason it didn't detect the wave properly. Perhaps it was a raw instead of pcm, or a non compatible sampling rate with window's sound recorder. Unfortunately I dont have the wave any longer, but I bet that was the issue, and excel added it as a "package".

thanks to both of your for helping track down this behavior. I'm sure others will/have encountered it too.

On a different but related note, it looks like this method is only capable of playing a sound synchronously. That is, the macro code pauses only to resume after the sound finishes. Not sure if there is a way to play a sound asynchronously. maybe there is a way to fork it (?)
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Well, I'm certainly glad you found an answer, tracks!

I still flounder quite a bit in vba, but just last week I wrote my first vba procedure completely from memory - so I must be learning something!

Regards,

Mitch
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top