Here is my code:
I create a shape in a slide powerpoint.
- Microsoft.Office.Interop.PowerPoint.Shape rectangle = curSlide.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRoundedRectangle, slideWidth - 110, slideHeight - 60, 100, 50);
- Sequence objSequence = curSlide.TimeLine.InteractiveSequences.Add(1);
- Effect pEffect_start = objSequence.AddEffect(rectangle, MsoAnimEffect.msoAnimEffectTransparency, MsoAnimateByLevel.msoAnimateLevelNone, MsoAnimTriggerType.msoAnimTriggerOnShapeClick, 1);
I can add an animation to shape, but with a sound I can not.
I want add a sound in this shape, when animation run so the sound is play.
How can I do that?
Shreyansh JainPosted Apr 1, 2017, 2:43 AM
Here are the steps:
Step 1: Create a new PowerPoint document first.
1Presentation presentation =newPresentation();Step 2: Then set the backgroung image before inserting Audio file.
1stringImageFile ="2.jpg";2RectangleF rect =newRectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);3presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);4presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;Step 3: Load the Audio file from disk and set properties of AutoShape
1presentation.Slides[0].Shapes.AppendAudioMedia(@"1.mp3",500,100,true);2IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle,newRectangleF(500, 100, 100, 150));3shape.ShapeStyle.LineColor.Color = Color.White;4shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;Step 4: Save the PowerPoint file and review.
1presentation.SaveToFile("audio.pptx", FileFormat.Pptx2010);2System.Diagnostics.Process.Start("audio.pptx");01Presentation presentation =newPresentation();0203stringImageFile ="2.jpg";04RectangleF rect =newRectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);05presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);06presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;0708presentation.Slides[0].Shapes.AppendAudioMedia(@"1.mp3",500,100,true);09IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle,newRectangleF(500, 100, 100, 150));10shape.ShapeStyle.LineColor.Color = Color.White;11shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;1213presentation.SaveToFile("audio.pptx", FileFormat.Pptx2010);14System.Diagnostics.Process.Start("audio.pptx");