Sub 删除空白页()
Dim p, l, myrange '申明页变量,行变量,和区域变量
p = ActiveDocument.Range.Information(wdActiveEndPageNumber) '获取文档总页数
Do While p > 1 '大于一页时开始循环
Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, count:=p, Name:="" '跳转到最后一页第一行
Selection.MoveUp Unit:=wdLine, count:=1 '向上移动一行
l = Selection.Information(wdFirstCharacterLineNumber) '获取当前页的行数
Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, count:=(p - 1), Name:="" '跳转到上一页第一行
Selection.EndKey Unit:=wdLine, Extend:=wdExtend '移动光标到行尾并选中
Selection.MoveDown Unit:=wdLine, count:=(l - 1), Extend:=wdExtend '移动光标选择这一页
Selection.EndKey Unit:=wdLine, Extend:=wdExtend '移动光标到行尾并选中
myrange = Selection.Text '获当前页内容
For i = 9 To 32 '
myrange = Replace(Trim(myrange), Chr(i), "") '删除回车键等
Next '
If Len(myrange) < 1 Then Selection.Delete '当前页内容为空白时删除
p = p - 1 '页数减少1页
Loop '结束循环
End Sub