public Presentation copySlide(int rowCount)
 {
     slide = presentation.Slides[1];
     slide.Copy();
     for (int i = 1; i <= rowCount; i++)
     {
         presentation.Slides.Paste(1);
     }
     return(presentation);
 }
        //Sample units
        public static void editExisting()
        {
            string source   = "D:\\Sample.pptx";
            string fileName = System.IO.Path.GetFileNameWithoutExtension(source);
            string filePath = System.IO.Path.GetDirectoryName(source);

            Application  pa = new Application();
            Presentation pp = pa.Presentations.Open(source,
                                                    MsoTriState.msoTrue,
                                                    MsoTriState.msoFalse,
                                                    MsoTriState.msoFalse);

            string pps = "";

            Slide sa = pp.Slides[1];

            sa.Copy();
            pp.Slides.Paste(1);

            foreach (Slide slide in pp.Slides)
            {
                foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in slide.Shapes)
                {
                    if (shape.HasTextFrame == MsoTriState.msoTrue)
                    {
                        var textFrame = shape.TextFrame;
                        if (textFrame.HasText == MsoTriState.msoTrue)
                        {
                            var textRange = textFrame.TextRange;
                            pps = textRange.Text.ToString();
                            if (pps.Contains("Heading"))
                            {
                                textRange.Text = "Changed Heading";
                            }
                            if (pps.Contains("Title Box"))
                            {
                                textRange.Text = "Changed Tiltle";
                            }
                            if (pps.Contains("Contents"))
                            {
                                textRange.Text = "Changed Contents1\nChanged Contents2";
                            }
                            Console.WriteLine(pps);
                        }
                    }
                }
            }
            pp.SaveAs("D:\\written.pptx");
            pa.Quit();
        }
Ejemplo n.º 3
0
 public void Copy()
 {
     _slide.Copy();
 }
 public void CopyToClipboard()
 {
     _slide.Copy();
 }