怎么写红包源代码( 二 )


{
//初始化控件值
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);
}

怎么写红包源代码

文章插图