Duplicate Slides Insertion using CommandBars.ExecuteMso("PasteSourceFormatting")
-
Friday, May 04, 2012 9:02 PM
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");
}
}
All Replies
-
Monday, May 07, 2012 5:45 AMModerator
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
- Marked As Answer by Tom_Xu_WXModerator Thursday, May 10, 2012 5:15 AM

