|
Sub DeletePages()
Dim startPage As Long
Dim endPage As Long
Dim doc As Document
Dim rng As Range
Set doc = ActiveDocument
startPage = InputBox("第几页")
endPage = InputBox("到第几页")
If startPage < 1 Or endPage > doc.Content.Information(wdNumberOfPagesInDocument) Then
MsgBox "无效页码", vbExclamation
Exit Sub
End If
Set rng = doc.Range
rng.Start = doc.GoTo(What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=startPage).Start
rng.End = doc.GoTo(What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=endPage + 1).Start
rng.Delete
MsgBox "第" & startPage & "页到第" & endPage & "页的内容已删除。", vbInformation
End Sub
|
|