依据目录分割word文档 word目录 分割分割 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 只能帮你到这里了http://wenku.baidu.com/view/80ec0a6c1eb91a37f1115cab.html 把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;//启用分割按钮 })); }); } 用asp.net开发网站 如何考虑日后流量问题?谢谢 (未处理SocketException)远程主机强迫关闭了一个现有的连接。 session 超时的问题 存储过程 传参数问题 ++++++++++++++++菜鸟问题+++++++++++++++ 在asp.net里面使用htc的问题,高分相赠 如何限制同一账号在不同IP上进行登陆? 自动生成试卷的代码怎么写? .net 2003的代码自动完成在哪? (高分求救)如何循环插入10万多条纪录 entity 如何为dbcontext运行时动态附加上一个dbset 怎么传值给json格式文件或者说修改json中的数据?
http://wenku.baidu.com/view/80ec0a6c1eb91a37f1115cab.html
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;//启用分割按钮
}));
});
}