vsto c# 获取word里面的图片并保存
internal void GetEmbeddedImages() { int i = 0; Document doc = Globals.ThisAddIn.Application.ActiveDocument; foreach (Microsoft.Office.Interop.Word.InlineShape ils in doc.InlineShapes) { if (ils != null) { i = i + 1; if (ils.Type == Microsoft.Office.Interop.Word.WdInlineShapeType.wdInlineShapePicture) { ils.Select(); Globals.ThisAddIn.Application.Selection.CopyAsPicture(); IDataObject ido = Clipboard.GetDataObject(); if (ido != null) { if (ido.GetDataPresent(DataFormats.Bitmap)) { Bitmap bmp = (Bitmap)ido.GetData(DataFormats.Bitmap); string filename = @"C:\Users\Pictures\savedoc\" + i.ToString() + ".jpg"; bmp.Save(filename, ImageFormat.Jpeg); } } } } } MessageBox.Show("finished"); } }