none
Duplicate Slides Insertion using CommandBars.ExecuteMso("PasteSourceFormatting") RRS feed

  • Question

  • Hello,

    I am copying all slides from a Presentation (PowerPoint 2003) to another presentation (PowerPoint 2010). I am not sure what I missed, when I executed the code below, I got the same number of slides on the destination presentation but each slide is the same last slide on the source. Any idea? Thanks!

    private void InsertWithKeepSourceFormatting(Microsoft.Office.Interop.PowerPoint.Presentation source,
                Microsoft.Office.Interop.PowerPoint.Presentation target)
            {
                 foreach (Slide slide in source.Slides)
                {
                    slide.Copy();
                    int y = slide.SlideID;
                    target.Windows[1].Activate();
                    Globals.ThisAddIn.Application.CommandBars.ExecuteMso("PasteSourceFormatting");
                   
                }
           }

    Friday, May 4, 2012 9:02 PM

Answers

  • Hi May-Yin,

    Thanks for posting in the MSDN Forum.

    I can't reproduce your issue. the following snippet is used to check your scenario on my side:

                PowerPoint.Presentation target =  Globals.ThisAddIn.Application.ActivePresentation;
                PowerPoint.Application ap = new PowerPoint.Application();
                PowerPoint.Presentation ps = ap.Presentations.Open(@"C:\Users\v-yangxu\Desktop\Presentation1.pptx");
                ap.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                foreach (PowerPoint.Slide slide in ps.Slides)
                {
                    slide.Copy();
                    int y = slide.SlideID;
                    target.Windows[1].Activate();
                    Globals.ThisAddIn.Application.CommandBars.ExecuteMso("PasteSourceFormatting");
                }
                ap.Quit();

    There hasn't duplicate slide between two presentations.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, May 7, 2012 5:45 AM
    Moderator