码迷,mamicode.com
首页 > 其他好文 > 详细

将word内容追击到新建WORD文档

时间:2017-09-30 13:28:50      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:sys   serve   rda   temp   mat   inter   graphs   dap   form   

将word内容追击到新建WORD文档

            Microsoft.Office.Interop.Word._Application wordApp = new Microsoft.Office.Interop.Word.Application();
            wordApp.Visible = false;
            Object Nothing = System.Reflection.Missing.Value;
            Microsoft.Office.Interop.Word._Document document = new DocumentClass();
            Microsoft.Office.Interop.Word._Document tempdocument = new DocumentClass();
            object objTemplate = Server.MapPath(@"~\\wordModel\demo.doc");

            document = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            for (int i = 0; i < 3; i++)
            {
                //document.Content.
                if (i > 0)
                {
                    Microsoft.Office.Interop.Word.Paragraph para;
                    para = document.Content.Paragraphs.Add(ref Nothing);
                    object pBreak = (int)WdBreakType.wdSectionBreakNextPage;
                    para.Range.InsertBreak(ref pBreak);

                }
                tempdocument = wordApp.Documents.Open(objTemplate);

                Range range = tempdocument.Range(ref Nothing, ref Nothing);
                range.Copy();
                document.Paragraphs.Last.Range.PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting);
            }

 

将word内容追击到新建WORD文档

标签:sys   serve   rda   temp   mat   inter   graphs   dap   form   

原文地址:http://www.cnblogs.com/lee24789229/p/7614340.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!