怎么让word自动删除第3、6、9、12等3的倍数页‘

Sub kk1206190933()
Dim wNum As Integer
Dim wPag As Integer
With Selection
wPag = .Information(wdNumberOfPagesInDocument)
For wNum = Int(wPag / 3) * 3 To 3 Step -3
.GoTo wdGoToPage, , wNum
.Bookmarks("\Page").Range.Delete
Next
End With
End Sub

VBA实现检查和删除Word中的空白页

Sub GetBlankPage()
Dim IsDelete As Boolean
Dim PageCount As Long
Dim rRange As Range
Dim iInt As Integer, DelCount As Integer
Dim tmpstr As String IsDelete = True
PageCount = ThisDocument.BuiltInDocumentProperties(wdPropertyPages)
For iInt = 1 To PageCount
'超过PageCount退出
If iInt > PageCount Then Exit For '取每一页的内容
If iInt = PageCount Then
Set rRange = ThisDocument.Range( _
Start:=ThisDocument.GoTo(wdGoToPage, wdGoToAbsolute, iInt).Start)
Else
Set rRange = ThisDocument.Range( _
Start:=ThisDocument.GoTo(wdGoToPage, wdGoToAbsolute, iInt).Start, _
End:=ThisDocument.GoTo(wdGoToPage, wdGoToAbsolute, iInt + 1).Start _
)
End If If Replace(rRange.Text, Chr(13), "") = "" Or Replace(rRange.Text, Chr(13), "") = Chr(12) Then
tmpstr = tmpstr & "第 " & iInt & " 页是空页" & vbCrLf
'删除?
If IsDelete Then
DelCount = DelCount + 1
'删除空白页
rRange.Text = Replace(rRange.Text, Chr(13), "")
rRange.Text = ""
'重算页数
PageCount = ThisDocument.BuiltInDocumentProperties(wdPropertyPages)
If iInt <> PageCount Then
'页删除后,页码变化,重新检查当前页
iInt = iInt - 1
Else
'最后一个空页
Set rRange = ThisDocument.Range( _
Start:=ThisDocument.GoTo(wdGoToPage, wdGoToAbsolute, PageCount - 1).Start, _
End:=ThisDocument.GoTo(wdGoToPage, wdGoToAbsolute, PageCount + 1).Start _
)
'如果是分页符,删除上一页中的换页符
If InStr(1, rRange.Text, Chr(12)) > 0 Then
rRange.Characters(InStr(1, rRange.Text, Chr(12))) = ""
Else
'没有分页符,通过选中后删除,最好不这样做,如果判断错误,有误删除的风险
Set rRange = ThisDocument.Range( _
Start:=ThisDocument.GoTo(wdGoToPage, wdGoToAbsolute, iInt).Start)
rRange.Select
Selection.Delete
End If
Exit For
End If
End If
End If
Next If 1 = 1 Or Not IsDelete Then
If tmpstr = "" Then
MsgBox "没有空页", vbInformation + vbOKOnly
Else
MsgBox tmpstr, vbInformation + vbOKOnly
End If
Else
If DelCount > 0 Then MsgBox "删除空页 " & DelCount, vbInformation + vbOKOnly
End If
End Sub

  

Sub AA()

Dim myRange As Range

Dim wNum As Integer
Dim wPag As Integer
Dim start As Integer wPag = Selection.Information(wdNumberOfPagesInDocument)
Selection.GoTo wdGoToPage, wdGoToAbsolute, 3
MsgBox (Selection.Range.start & "+" & Selection.Range.End)
start = Selection.Range.start '.EndKey Unit:=wdStory
'myRange.End = .Range.Start
'MsgBox (myRange.Text)
'If Replace(.Range.Text, Chr(13), "") = "" Or Replace(.Range.Text, Chr(13), "") = Chr(12) Then
'.Bookmarks("\Page").Range.Delete
'End If Selection.EndKey Unit:=wdStory
Selection.Select
MsgBox (Selection.Range.start & "+" & Selection.Range.End)
'Set myRange = ActiveDocument.Range(ActiveDocument.GoTo(wdGoToPage, wdGoToAbsolute, 3).start, End:=ActiveDocument.GoTo(wdGoToPage, wdGoToAbsolute, 3).start) Set myRange = ActiveDocument.Range(start, End:=Selection.start) MsgBox (myRange.Text) End Sub

  

VBA 删除页的更多相关文章

  1. C# 操作Word页眉页脚——奇偶页/首页不同、不连续设置页码、复制页眉页脚、锁定页眉页脚、删除页眉页脚

    前言 本文是对Word页眉页脚的操作方法的进一步的阐述.在“C# 添加Word页眉页脚.页码”一文中,介绍了添加简单页眉页脚的方法,该文中的方法可满足于大多数的页眉页脚添加要求,但是对于比较复杂一点的 ...

  2. VBA删除表格最后一行

    Sub 删除最后一行() If MsgBox("要为所有表格添加列吗?", vbYesNo + vbQuestion) = vbYes Then To ActiveDocument ...

  3. VBA 删除Excel中所有的图片

    Sub DeletePic()     Dim p As Shape     For Each p In Sheet1.Shapes         If p.Type = Then         ...

  4. VBA删除 语法

    Option Explicit '清空数据  Private Sub CommandButton1_Click() Dim qknum As Integer  '选择是或者否 来确认删除数据 '中对话 ...

  5. MVC入门——删除页

    添加Action DeleteUserInfo using System; using System.Collections.Generic; using System.Linq; using Sys ...

  6. VBA删除空白行列

    '删除空行 Sub DeleteEmptyRows() Dim LastRow As Long, r As Long LastRow = ActiveSheet.UsedRange.Rows.Coun ...

  7. [VBA]删除多余工作表

    sub 删除多余工作表() Dim i As Integer Application.DisplayAlerts = False For i = Worksheets.Count To 1 step ...

  8. 怎么样在同一个word文件中删除不同节数的页眉

    1.双击页眉,进入页眉编辑状态2.选择准备删除页眉的节,直接额删除即可.注意:为不至于因该节的改动影响其他节的页眉,需要在页眉设置上,每节都要取消链接到前一节页眉 把那张的前面和后面都插入分隔符,在页 ...

  9. 多iframe使用tab标签方式添加、删除、切换的处理实例

    紧接着上一篇随笔iframe的内容增高或缩减时设置其iframe的高度的处理方案 如果采用iframe来切换显示内容的方式来展现办公Web.那么需要解决几个问题 1.tab标签需要和显示的iframe ...

随机推荐

  1. JavaScript原生实现《贪吃蛇》

    概述 JavaScript原生实现<贪吃蛇>,每吃掉一个食物,蛇的身体会变长,食物会重新换位置. 详细 代码下载:http://www.demodashi.com/demo/10728.h ...

  2. PHP-数据库永久连接

    以下为PHP官网上对数据库永久连接做的解释: 永久的数据库连接是指在脚本结束运行时不关闭的连接.当收到一个永久连接的请求时.PHP 将检查是否已经存在一个(前面已经开启的)相同的永久连接.如果存在,将 ...

  3. 去掉cb中括号的匹配

    Settings->Editor->General settings->Indent options->Brace completion``

  4. jQuery动态表格插件 AppendGrid

    AppendGrid是一个jQuery动态表格插件,提供像填写电子表格数据一样在页面去输入结构化数据. 它允许用户在表格里增加/删除/插入/删除行,控制input/select/textarea 提交 ...

  5. Ubuntu 10.04 安装流程

    ubuntu 10.04 安装流程   需安装libxrender-dev才能跑html5           来自为知笔记(Wiz)

  6. Report_SRW工具的基本用法(概念)

    2014-05-31 Created By BaoXinjian

  7. ubuntu14.4开启ftp服务

    1 更新源列表 打开"终端窗口",输入"sudo apt-get update"-->回车-->"输入当前登录用户的管理员密码" ...

  8. 为 Blade 模板引擎添加新文件扩展名

    因为一些原因,我准备把 Blessing Skin 的框架换成 Laravel 了(之前是自己搭建的一个框架),但是在模板迁移的时候遇到了一点问题. 之前我是使用的 XiaoLer/blade 这个从 ...

  9. unity5, Configurable Joint: Anchor, Connected Anchor, Auto Configure Connected Anchor

    configurable joint加在轮子上,connected body是车身. 这种情况下,Anchor=(0,0,0)表示轮子一端joint锚点取carWheelCenter Connecte ...

  10. cocos2dx 3.x 避免空sprite

    由于cocos2dx 3.x中autobatch的,如果场景中含有空sprite(并且还不处于visible==false状态)的话,则会打断流水线(因为空sprite的贴图与其它元素的贴图必定不在同 ...