乔山办公网我们一直在努力
您的位置:乔山办公网 > office365 > 批量删除word文档某一页 VBA

批量删除word文档某一页 VBA

作者:乔山办公网日期:

返回目录:office365


使用Dir函数,把你的文件夹中的word文档名全部找出来。然后用documents.open方法,逐个打开文档改字体颜色。
参考:

Dim MyDoc$MyDoc = Dir("C:\Documents and Settings\user\My Documents\*.doc")Debug.Print MyDocDo While MyDoc <> "" MyDoc = Dir Debug.Print MyDocLoop

open方法是这样:
Documents.Open FileName:=ThisDocument.Path & "\" & MyDoc
你自己整合一起吧,这就不多说了

你的那些关键字,没必要用字典保存啊,用Array函数更方便了。
Dim KeyWords as Variant
KeyWords=Array("关键词1",“关键词2”,……)

vba 批量删除 word 内容吗?
Sub Macro4()
Dim i As Paragraph
Application.ScreenUpdating = False
For Each i In ActiveDocument.Paragraphs
Selection.Find.ClearFormatting
Selection.Find.Text = "所含的关字"
Selection.Find.Execute
If Selection.Text <> "" Then
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
End If
Next
End Sub
把代码中所含的关键字几个字改成你想要的就可以了

Public StartPageNum As Integer, EndPageNum As Integer

Sub aaa()

Dim myDialog As FileDialog, oFile As Variant, oDoc As Document
On Error Resume Next

Set myDialog = Application.FileDialog(msoFileDialogFilePicker)

myDialog.Filters.Clear '清除所有文件筛选器中的项目
myDialog.Filters.Add "所有 WORD 文件", "*.doc", 1 '增加筛选器的项目为所有WORD文件
myDialog.AllowMultiSelect = True '允许多项选择

If myDialog.Show <> -1 Then Exit Sub

Dim SelectRange As Range
DlgDelePage.Show vbModal
If StartPageNum = 0 And EndPageNum = 0 Then
Exit Sub
End If

For Each oFile In myDialog.SelectedItems '在所有选取项目中循环

Set oDoc = Documents.Open(FileName:=oFile, Visible:=True) 'False)

Dim Pages As Integer, StartPage As Long, EndPage As Long

Pages = Selection.Information(wdNumberOfPagesInDocument)

If Not (StartPageNum > Pages) Then
If EndPageNum > Pages Then EndPageNum = Pages

If StartPageNum = 1 Then
StartPage = Selection.Range
Else
StartPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=StartPageNum - 1).Start
End If

If EndPageNum = Pages Then
EndPage = ActiveDocument.Content.End
Else
EndPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=IIf(EndPageNum - StartPageNum > 0, EndPageNum - StartPageNum + 1, 1)).End '.Start
End If

ActiveDocument.Range(StartPage, EndPage).Select
Selection.Delete

End If

'删除第e79fa5e98193e58685e5aeb93343页批注
ActiveDocument.Words(1).Select '将光标移到文档开始位置
Dim myRange As Range, oComment As Comment
Set myRange = Selection.Range
StartPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=3 - 1).Start
EndPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=3 - 1).End

myRange = ActiveDocument.Range(StartPage, EndPage)

If myRange.Comments.Count > 0 Then
For Each oComment In myRange.Comments
oComment.Delete
Next
End If

oDoc.Save
oDoc.Close

Next oFile

End Sub

相关阅读

  • 批量删除word文档某一页 VBA

  • 乔山办公网office365
  • 使用Dir函数,把你的文件夹中的word文档名全部找出百来。然后用documents.open方法,逐个打开文档改度字体颜色。参考:Dim MyDoc$MyDoc = Dir("C:Documents and SettingsuserMy Documents*.doc")Debug.Print My
  • excel VBA 宏禁止

  • 乔山办公网office365
  • 从你的描述上看,应该是VBA代码有不合百理度的地方,我经常打开上百兆的EXCEL文件,很少遇到系统奔溃。给你一个知建议,把代码和数据分开,把所有的道VBA代码转移到一个XLAM文件中
  • wps pro plus 2016和专业版有什么区别

  • 乔山办公网office365
  • 增加Access、Skype for Business、InfoPath组件,标准版是没有这些组件的。office2016密钥(正式版)" src="/uploads/tu/682.jpg" style="width: 400px; height: 267px;" />一、方法一:来根据安装特点区分
  • Excel 求助<em>VBA</em>代码实现查询功能

  • 乔山办公网office365
  • 添加百X = WorksheetFunction.CountIf(Sheets("数据存度储页知面中道").Range("B:B"), [E6])If X = 0 ThenMsgBox "不存回在答"ElseMsgBox "存在"End IfVBA实现多条件查询数据?" src="/uploads/
关键词不能为空
极力推荐
  • 找不到文件c:&#92;program Files&#92;Common F...

  • 可能的原因及解决办法:文件不存在(用资源管理copy器浏览到这个文件夹,看不到这个文件);百下载这个文件到指定文件夹,并执行2存在这个文件,但是没有注册;在开始-运行中输

ppt怎么做_excel表格制作_office365_word文档_365办公网