Reputation: 85
Does anyone know how to save Background image of slide in powerpoint presentation (2010). Here is a part of my code where i'm trying to clear slide to get the background image but it's not quite the desired result
PowerPoint.Presentation p = app.Presentations.Open(slidesContainerPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
string imagename;
foreach (PowerPoint.Slide s in p.Slides) {
imagename = s.SlideIndex.ToString() + ".jpg";
s.BackgroundStyle = Microsoft.Office.Core.MsoBackgroundStyleIndex.msoBackgroundStyleNotAPreset;
foreach(Microsoft.Office.Interop.PowerPoint.Shape shape in s.Shapes)
{
shape.Delete();
}
s.Export(imagesContainerPath + "\\" + imagename, "JPG");
}
if (p != null) {
p.Close();
}
Upvotes: 1
Views: 1514
Reputation: 26
It's easier to help you solve a problem if you STATE the problem. You say "it's not quite the desired result". That could mean many things, from "nothing happens" to "my computer explodes". ;-)
If I had to guess (and I do), I'd say that you're probably seeing every other shape deleted from the slides rather than every shape. Instead of a foreach loop, use something like this (VB/VBA, translate as needed):
For x = s.Shapes.Count to 1 Step -1
sShapes(x).Delete
Next
That will delete ALL of the shapes on a slide.
Or just this instead of a loop:
s.Shapes.ShapeRange.Delete
Upvotes: 1