解决方案 »

  1.   

    只能帮你到这里了
    http://wenku.baidu.com/view/80ec0a6c1eb91a37f1115cab.html
      

  2.   

    把word文档分割成多个小word文档
      private Word.Application G_wa;//定义Word应用程序字段
            private object G_missing = //定义G_missing字段并添加引用
                System.Reflection.Missing.Value;
            private OpenFileDialog G_OpenFileDialog;//定义打开文件对话框字段
            private FolderBrowserDialog G_FolderBrowserDailog;//定义浏览文件夹对话框字段        private void btn_Get_Click(object sender, EventArgs e)
            {
                btn_split.Enabled = false;//停用分割按钮
                ThreadPool.QueueUserWorkItem(//开始线程池
                    (pp) =>//使用lambda表达式
                    {
                        G_wa = new Microsoft.Office.Interop.Word.Application();//创建应用程序对象
                        object P_OpenFileDialog = //创建object对象
                            G_OpenFileDialog.FileName;
                        Word.Document P_Document = G_wa.Documents.Open(//打开Word文档
                            ref P_OpenFileDialog, ref G_missing, ref G_missing, ref G_missing
                            , ref G_missing, ref G_missing, ref G_missing, ref G_missing
                            , ref G_missing, ref G_missing, ref G_missing, ref G_missing
                            , ref G_missing, ref G_missing, ref G_missing, ref G_missing);
                        bool P_bl = false;
                        this.Invoke(//调用窗体线程
                             (MethodInvoker)(() =>//使用lambda表达式
                                {
                                    P_bl = cbox_Select.SelectedIndex == 0;
                                }));
                        if (P_bl)//判断使用什么方式分割文档
                        {
                            foreach (Word.Paragraph Paragraph in G_wa.ActiveDocument.Paragraphs)
                            {
                                Paragraph.Range.Select();//选择段落
                                Paragraph.Range.Copy();//将段落放入剪切板
                                AddFile();//将剪切板内的数据放入新建文件
                            }
                        }
                        else
                        {
                            Word.Range P_Range = G_wa.ActiveDocument.Content;//得到文档区域
                            int P_int_count = P_Range.Text.Length;//得到文档字符总长度
                            int P_int_i = P_int_count / 100;//计算循环建立文档次数
                            if (P_int_i > 0)//如果文档内文字大于100个
                            {
                                for (int i = 0; i < P_int_i; i++)//开始循环创建文档
                                {
                                    object P_o1 = i == 0 ? 0 : i * 100 + 1;//复制文档范围的开始部份
                                    object P_o2 = i * 100 + 101;//复制文档范围的结尾部份
                                    Word.Range P_Range_temp = //得到文档的范围
                                        G_wa.ActiveDocument.Range(ref P_o1, ref P_o2);
                                    P_Range.Select();//选中文档范围
                                    P_Range_temp.Copy();//将选择文档范围放入剪切板
                                    AddFile();//将剪切板内的数据放入新建文件
                                }
                                object P_o11 = P_int_i * 100 + 1;//复制文档范围的开始部份
                                Word.Range P_Range_temp1 = //得到文档的范围
                                    G_wa.ActiveDocument.Range(ref P_o11, ref G_missing);
                                P_Range.Select();//选中文档范围
                                P_Range_temp1.Copy();//将选择文档范围放入剪切板
                                AddFile();//将剪切板内的数据放入新建文件
                            }
                            else
                            {
                                Word.Range P_Range2 = //得到文档区域
                                    G_wa.ActiveDocument.Content;
                                P_Range.Select();//选中文档范围
                                P_Range2.Copy();//将选择文档范围放入剪切板
                                AddFile();//将剪切板内的数据放入新建文件
                            }
                        }//CodeGo.net/
                        ((Word._Application)G_wa.Application).Quit(//退出应用程序
                            ref G_missing, ref G_missing, ref G_missing);
                        this.Invoke(//调用窗体线程
                            (MethodInvoker)(() =>//使用lambda表达式
                            {
                                Clipboard.Clear();//清空剪切板
                                MessageBox.Show(//提示已经创建Word
                                    "分割文档完成!", "提示!");
                                btn_split.Enabled = true;//启用分割按钮
                            }));
                    });
            }