Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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 :

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


How can I Do this in C#?

Please help me.
Thanks P2000
Posted
Updated 20-Apr-11 21:40pm
v2
Comments
Tarun.K.S 21-Apr-11 3:38am    
It is in C#. What is your doubt?
2000 P 21-Apr-11 4:39am    
I have to copy all the shapes from the PPT1's slide to PPT2's slide. But I am able to insert entire slide here. I want currently active slide should populate with shapes from PPT1. How can we do that?
Tarun.K.S 21-Apr-11 5:26am    
You can check my answer now.
Dalek Dave 21-Apr-11 3:41am    
Edited for Grammar and Readability.

1 solution

I am still quite unsure about the requirement here.

C#
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.
 
Share this answer
 
v2
Comments
Tarun.K.S 21-Apr-11 10:20am    
See my updated answer. Use "[" instead of "(" after Slides.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900