主题:问题出在哪?
Microsoft.Office.Interop.Word.Application newApp = new Microsoft.Office.Interop.Word.Application();
object filename = ".....";
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document doc = newApp.Documents.Open(ref filename,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing);
int count = doc.InlineShapes.Count;
for (int i = 0; i < count; i++)
{
if (doc.InlineShapes[i].Type == Microsoft.Office.Interop.Word.WdInlineShapeType.wdInlineShapePicture)
{
doc.InlineShapes[i].Select();
newApp.Selection.Copy();
Image image = Clipboard.GetImage();
if (image != null)
{
Bitmap bitmap = new Bitmap(image);
bitmap.Save(.....);
}
}
}
Console.WriteLine("程序运行成功");
这是一段程序用来打开一个word文档并把里面的图片提取出来放到指定的文件夹下,可是程序能编译成功,但是没提取出图片,程序中Image image = Clipboard.GetImage(); 这句返回值总是null ,麻烦谁能指点下
object filename = ".....";
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document doc = newApp.Documents.Open(ref filename,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing);
int count = doc.InlineShapes.Count;
for (int i = 0; i < count; i++)
{
if (doc.InlineShapes[i].Type == Microsoft.Office.Interop.Word.WdInlineShapeType.wdInlineShapePicture)
{
doc.InlineShapes[i].Select();
newApp.Selection.Copy();
Image image = Clipboard.GetImage();
if (image != null)
{
Bitmap bitmap = new Bitmap(image);
bitmap.Save(.....);
}
}
}
Console.WriteLine("程序运行成功");
这是一段程序用来打开一个word文档并把里面的图片提取出来放到指定的文件夹下,可是程序能编译成功,但是没提取出图片,程序中Image image = Clipboard.GetImage(); 这句返回值总是null ,麻烦谁能指点下