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");
        }
    }

 

vsto c# 获取word里面的图片并保存

上一篇:30.Jwt集成(4):请求tokenAPI、中间件的方式集成token认证、用户信息传递


下一篇:Winserver-禁止程序启动