c# word对其中一页删除的问题
word文档中比如有4页,只删除第2页,并在第2页插入新内容
我现在只能实现删除3、4页,不能删除第2页,代码如下:
//得到word文件页数
object IncludeFootnotesAndEndnotes = false;
int PageNum = Word_doc.ComputeStatistics(WdStatistic.wdStatisticPages, ref IncludeFootnotesAndEndnotes);
for (int i = 1; i <= PageNum; i++)
{
if (i == 2)//第2页时
{
Word.Range r1, r2;
object Unit = (int)Word.WdUnits.wdCharacter;
object Count = 1;
//Word_App.Selection.Range.Delete(ref Unit, ref Count);
r1 = Word_App.Selection.Range;
r2 = Word_App.ActiveDocument.Range(ref missing,ref missing);
object start = r1.Start;
object end = r2.End;
Word_App.ActiveDocument.Range(ref start,ref end).Delete(ref Unit,ref Count);
Word_App.Selection.Paste(); //粘贴
}
Word_doc.Application.Browser.Next();//下一页
}
大家帮帮我啊