C#将PPT形状(msoPicture)保存为带Office.Interop的图像 [英] C# Save PPT Shape (msoPicture) as Image w/ Office.Interop
本文介绍了C#将PPT形状(msoPicture)保存为带Office.Interop的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含多张图片的PPT幻灯片.我正在遍历每个幻灯片和每个形状.我想将msoPicture类型的每种形状另存为Image:
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);
}
}
}
推荐答案
You can use the Shape.Export()
method to create an image from an individual shape.
例如这样的
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);
}
}
}
这篇关于C#将PPT形状(msoPicture)保存为带Office.Interop的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文