如何将形状从一张幻灯片复制到另一张幻灯片?

问题描述:

我需要从presentation1到presentation2插入形状.
我们可以插入像
这样的幻灯片 pptApp.Presentations[Presentation2].Slides.InsertFromFile("presenation1", 10,2,2);

但是我只希望从Presentation1.slide(x)插入到Presentation2.slide(y)的形状.

像这样的东西:

I need to insert shape(s) from presentation1 to presentation2.
We can insert a slide like
pptApp.Presentations[Presentation2].Slides.InsertFromFile("presenation1", 10,2,2);

But I want only the shapes from Presentation1.slide(x) inserted to Presentation2.slide(y).

Something like this :

foreach (Microsoft.Office.Interop.PowerPoint.Shape shp in sld.Shapes)
                        {
                            shp.Copy();
                            Targetslide.Shapes.Paste();     
                            
                        }



如何在C#中做到这一点?

请帮帮我.
谢谢P2000



How can I Do this in C#?

Please help me.
Thanks P2000

我还是不太确定这里的要求.

I am still quite unsure about the requirement here.

pp.Presentation PPT1 = pptApp.Presentations["Presentation1"]; //get the PPT1 object

pp.Presentation PPT2 = pptApp.Presentations["Presentation2"]; // get the PPT2 object
pp.Slide ppt2ActiveSlide = PPT2.Slides[pptApp.ActiveWindow.Selection.SlideRange.SlideIndex]; // returns the active slide of PPT2

// This for loop will loop through all the slides and paste it in the Active Slide of PPT2
foreach(pp.Slide slide in PPT1.Slides)
{
 foreach(pp.Shape shp in slide.Shapes)
  {
   shp.Copy();
   ppt2ActiveSlide.Shapes.Paste();
  }
}



希望对您有所帮助.



Hope it helped.