{
//初始化控件值
ClearControl();
StringBuilder reportContent = new StringBuilder();
object Nothing = System.Reflection.Missing.Value;
object filename = "文件完整路径和名称";
Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Open(ref filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//循环文章中的各个章节
foreach (Paragraph item in WordDoc.Paragraphs)
{
if (item != null)
{
if (item.Range.Text.Trim() != "")
{
//判断该范围内是否存在图片
if (item.Range.InlineShapes.Count != 0)
{
foreach (InlineShape shape in item.Range.InlineShapes)
{
//判断类型
if (shape.Type == WdInlineShapeType.wdInlineShapePicture)
{
//利用剪贴板保存数据
shape.Select(); //选定当前图片
WordApp.Selection.Copy();//copy当前图片
string fileName = "";
if (Clipboard.ContainsImage())
{
【怎么写红包源代码】Bitmap bmp = new Bitmap(Clipboard.GetImage());
fileName = System.Guid.NewGuid() + ".png";
bmp.Save(savePath + fileName, System.Drawing.Imaging.ImageFormat.Png);
}
}
}
}
//在总目录中添加相应信息
reportContent.AppendLine(item.Range.Text.Trim());
}
}
}
WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
}
文章插图
- 随堂思考意见怎么写
- 我发明了洒水瓶作文怎么写
- 简单房屋协议书怎么写
- 怎么在上写钢笔字
- 幼儿园家长评议怎么写
- 朋友家装修开工怎么写
- 你好东京日语怎么写
- 她是谁用英语怎么写
- 怀孕期间感冒了怎么办 怀孕期间感冒了能吃药吗
- 白水煮虾蘸料怎么调 白水煮虾蘸料