首页 新闻 会员 周边

文档的合并代码,求解释

0
[已关闭问题] 关闭于 2011-07-20 12:10

//合并
            object wdunit = WdUnits.wdStory; object wdEx = WdMovementType.wdExtend;
            object saveChanges = false, of = Word.WdOriginalFormat.wdOriginalDocumentFormat, rd = System.Reflection.Missing.Value;
            //wClass.WordApplication.Quit(ref saveChanges, ref of, ref rd);

            saveChanges = false; of = Word.WdOriginalFormat.wdOriginalDocumentFormat; rd = System.Reflection.Missing.Value;
            //wClass2.WordApplication.Quit(ref saveChanges, ref of, ref rd);

            lblTip.Text = "正在合并, 请等待... ";
            //wClass = new WordClass();
            wClass.OpenWordDoc(FileOperate.WellHistoryPath + @"\00.doc");

            System.Threading.Thread.Sleep(200);


            for (int j = 1; j <= clbPart.Items.Count; j++)
            {
                if (isCancel == true)
                    return;

                if (jsArr[j, 0] == "1")  // '如果是"1", 则选择了该项
                {
                    //wClass.delEndBLKLine();
                    wClass.WordApplication.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
                    a1 = ""; a2 = false; a3 = false; a4 = false;
                    string docfilename = FileOperate.WellHistoryPath + @"\" + j.ToString("0#") + ".doc";
                    wClass.GotoWordEnd(false);
wClass.WordApplication.Selection.InsertFile(docfilename, ref a1, ref a2, ref a3, ref a4);


                    System.Windows.Forms.Application.DoEvents();
                    System.Threading.Thread.Sleep(100);
                }
            }
            wClass.GotoWordBegin(false);
    wClass.ReplaceAll("###JH###", JH);

            for (int i = 2; i <= wClass.WordApplication.ActiveDocument.Sections.Count; i++)
            {
                wClass.GotoWordSection(i);
                if (wClass.WordApplication.ActiveWindow.ActivePane.View.Type == WdViewType.wdNormalView
                    || wClass.WordApplication.ActiveWindow.ActivePane.View.Type == WdViewType.wdOutlineView)
                    wClass.WordApplication.ActiveWindow.ActivePane.View.Type = WdViewType.wdPrintView;
                wClass.WordApplication.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekCurrentPageHeader;
                wClass.GotoWordEnd(false)
                wClass.ReplaceAll("###JH###", JH);
wClass.SaveAs(FileOperate.WellHistoryPath + @"\" + JH + "措施施工设计.doc");
            wClass.Close(true);
            //
            string strMoudleFile = FileOperate.WellHistoryPath + @"\" + JH + "措施施工设计.doc";
            if (File.Exists(strMoudleFile))
            {
                Process p = new Process();
                p.StartInfo.FileName = strMoudleFile;
                p.StartInfo.UseShellExecute = true;
                p.StartInfo.CreateNoWindow = true;
                p.Start();
            }

帅哥跪下叫春的主页 帅哥跪下叫春 | 初学一级 | 园豆:200
提问于:2011-06-26 11:44
< >
分享
所有回答(1)
0

1、好歹悬赏点豆子,不然哪有人来看;

2、求解释,解释什么?每句代码都给你解释?那代价可不小哦~

today4king | 园豆:3499 (老鸟四级) | 2011-07-20 12:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册