I need an application to copy text and images from PowerPoint to Word. I use these libraries: Microsoft.Office.Interop.PowerPoint and Microsoft.Office.Interop.Word.
The text is easy to carry, but when I find in PowerPoint a form containing only an image, it shows this error: " General GDI + error ", in this part of the code:
foreach (PowerPoint.Shape shape in slide.Shapes)
{
if (shape.HasTextFrame != MsoTriState.msoTrue){
shape.Copy();
Image img = (Image)Clipboard.GetData(DataFormats.Bitmap);
string filepath = Environment.SpecialFolder.Desktop + "\\img.jpg";
if (File.Exists(filepath))
{
File.Delete(filepath);
}
img.Save(filepath);
doc.Shapes.AddPicture(filepath, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
}
}
How can I copy a shape containing an image from PowerPoint to Word under these conditions? Any help is appreciated. I prefer sample code.
Thank.
source
share