Example #1
0
        private void buttonModify_Click(object sender, EventArgs e)
        {
            if (!File.Exists(orgFileName))
            {
                return;
            }

            try
            {
                var file = new PPT.Application().Presentations.Open(orgFileName, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);

                foreach (PPT.Slide slide in file.Slides)
                {
                    foreach (PPT.Shape shape in slide.Shapes)
                    {
                        if (shape.Type == MsoShapeType.msoMedia)
                        {
                            if (shape.MediaType == PPT.PpMediaType.ppMediaTypeMovie || shape.MediaType == PPT.PpMediaType.ppMediaTypeSound)
                            {
                                if (checkBoxVolume.Checked == true)
                                {
                                    shape.MediaFormat.Volume = (float)numericUpDownVolume.Value / 100.0f;
                                }
                                if (radioButtonUnmuteAll.Checked == true)
                                {
                                    shape.MediaFormat.Muted = false;
                                }
                                else if (radioButtonMuteAll.Checked == true)
                                {
                                    shape.MediaFormat.Muted = true;
                                }
                            }
                        }
                    }
                }


                file.SaveAs(modifiedFileName);

                file.Close();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }