问题
I have a PPT slide deck with multiple images. I am iterating through each slide and each shape. I would like to save each shape of type msoPicture as an Image:
foreach (PPT.Slide slide in pptDoc.Slides)
{
foreach (PPT.Shape shape in slide.Shapes)
{
if (shape.Type == Microsoft.Office.Core.MsoShapeType.msoPicture)
{
Image img;
//???? Save shape as image
img.Save(filename);
}
}
}
回答1:
You can use the Shape.Export() method to create an image from an individual shape.
For example like this:
foreach (PPT.Slide slide in pptDoc.Slides)
{
foreach (PPT.Shape shape in slide.Shapes)
{
if (shape.Type == Microsoft.Office.Core.MsoShapeType.msoPicture)
{
shape.Export(filename, Microsoft.Office.Interop.PowerPoint.PpShapeFormat.ppShapeFormatPNG);
}
}
}
来源:https://stackoverflow.com/questions/42442659/c-sharp-save-ppt-shape-msopicture-as-image-w-office-interop