I am working on a VSTO PowerPoint 2007 add-in and I am running a small issue. The add-in adds sounds to the current slide using the following code:
var shape = slide.Shapes.AddMediaObject(soundFileLocation, 50, 50, 20, 20);
The resulting form has a sound and can be played through a PowerPoint slide. My problem is that, given the link to the form that was created this way, I would like to programmatically play the sound, but I cannot find a way to do this. I tried
var soundEffect = shape.AnimationSettings.SoundEffect; soundEffect.Play();
but this does not work / crash, and when I check soundEffect its type is ppsoundNone.
Edit: Gained partial success using
var shape = slide.Shapes.AddMediaObject(fileLocation, 50, 50, 20, 20); shape.AnimationSettings.SoundEffect.ImportFromFile(fileLocation);
This allows me to play sound with:
var animationSettings = shape.AnimationSettings; var soundEffect = shape.AnimationSettings.SoundEffect; soundEffect.Play();
However, there is one serious problem; this only works to add the last shape. For some reason, shape.AnimationSettings.SoundEffect.ImportFromFile (fileLocation) seems to reset the SoundEffect property for ppSoundNone for previously created forms ...
I would be surprised if this were not possible, but I cannot find how ... any help would be greatly appreciated!