Note that there are some explanatory texts on larger screens.

plurals
  1. POProgrammatically play the sound of a shape in PowerPoint
    primarykey
    data
    text
    <p>I am working on a PowerPoint 2007 VSTO add-in, and I am running in a small issue. The add-in adds sounds to the current slide using the following code:</p> <pre><code>var shape = slide.Shapes.AddMediaObject(soundFileLocation, 50, 50, 20, 20); </code></pre> <p>The resulting shape does have a sound, and can be played through the PowerPoint slide. My problem is that, given a reference to a shape that has been created that way, I would like to programmatically play the sound, but I can't find the way to do it. I tried</p> <pre><code>var soundEffect = shape.AnimationSettings.SoundEffect; soundEffect.Play(); </code></pre> <p>but this fails/crashes, and when I check soundEffect, its type is ppSoundNone.<br> <strong>Edit:</strong> got some partial success with</p> <pre><code>var shape = slide.Shapes.AddMediaObject(fileLocation, 50, 50, 20, 20); shape.AnimationSettings.SoundEffect.ImportFromFile(fileLocation); </code></pre> <p>Doing this allows me to play the sound with:</p> <pre><code>var animationSettings = shape.AnimationSettings; var soundEffect = shape.AnimationSettings.SoundEffect; soundEffect.Play(); </code></pre> <p>However there is one major issue; this works only for the last shape added. For some reason, shape.AnimationSettings.SoundEffect.ImportFromFile(fileLocation) seems to reset the SoundEffect property to ppSoundNone for the shapes previously created... </p> <p>I would be surprised if this wasn't feasible, but I can't seem to find how - any help would be much appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload