怎么让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.Del
Word中的书签功能可快速.准确定位文档中特定的位置,经常用于模板定制.文档产出等. 可一直以来,书签功能存在一个不便的操作,即无法批量删除,只能单个删除,操作极不友好. 解决方案 我用代码暂时还改变不了世界,但可以提高工作效率.使用两VBA代码,即可完成遍历.删除. ALT+F11,打开VBA编辑器,在ThisDocument页面写下语句,F5执行即可. Sub DelBookmarks() Dim MyBk As Bookmark For Each MyBk In ActiveDocumen
Sub 删除最后一行() If MsgBox("要为所有表格添加列吗?", vbYesNo + vbQuestion) = vbYes Then To ActiveDocument.Tables.Count ActiveDocument.Tables(i).Rows.Last.Delete Next MsgBox ("完成") Else MsgBox ("任务取消") End If End Sub
Option Explicit '清空数据 Private Sub CommandButton1_Click() Dim qknum As Integer '选择是或者否 来确认删除数据 '中对话框类型 16+4 :16指图标类型是停止图标,4指出现的按钮是“是”“否”按钮 If (MsgBox("确定删除所有数据吗?", vbCritical + 16 + 4, "温馨提示") = vbNo) Then Exit Sub End If ' 要清
'删除空行 Sub DeleteEmptyRows() Dim LastRow As Long, r As Long LastRow = ActiveSheet.UsedRange.Rows.Count LastRow = LastRow + ActiveSheet.UsedRange.Row - Then Rows(r).Delete Next r End Sub '删除空列 Sub DeleteEmptyColumns() Dim LastColumn As Long, c As Long
sub 删除多余工作表() Dim i As Integer Application.DisplayAlerts = False For i = Worksheets.Count To 1 step -1 If i >7 Then ThisWorkbook.Worksheets(i).Delete End If Next Application.DisplayAlerts = True End Sub
原文地址 本文的对象是:有一定Excel VBA基础,对Word VBA还没有什么认识,想在Excel中通过VBA操作Word还有困难的人. 一.新建Word引用 需要首先创建一个对 Word Application 对象的引用.在VBA中,工具-引用,选取“MicroSoft Word 11.0 Object Library”. 方法一.New Word.Application Dim Wordapp As Word.Application Set Wordapp = Ne