批量word删除页眉页脚——VBS脚本,在office宏中运行即可
批量word刪除頁眉頁腳——VBS腳本,在office宏中運行即可?
Sub 批量刪除頁眉頁腳()
'此代碼功能為列出指定文件夾中所有選取的WORD文件全路徑名
Dim myDialog As FileDialog, oDoc As Document, oSec As Section
Dim oFile As Variant, myRange As Range
On Error Resume Next
'定義一個文件夾選取對話框
Set myDialog = Application.FileDialog(msoFileDialogFilePicker)
With myDialog
.Filters.Clear '清除所有文件篩選器中的項目
.Filters.Add "所有Word文件", "*.doc,*.docx", 1 '增加篩選器的項目為所有Word文件
.AllowMultiSelect = True '允許多項選擇
If .Show = -1 Then '確定
For Each oFile In .SelectedItems '在所有選取項目中循環
Set oDoc = Word.Documents.Open(FileName:=oFile, Visible:=False)
For Each oSec In oDoc.Sections '文檔的節中循環
Set myRange = oSec.Headers(wdHeaderFooterPrimary).Range
myRange.Delete '刪除頁眉中的內容
myRange.ParagraphFormat.Borders(wdBorderBottom).LineStyle = wdLineStyleNone '段落下邊框線
Set myRange = oSec.Footers(wdHeaderFooterPrimary).Range
myRange.Delete '刪除頁腳中的內容
Next
oDoc.Close True
Next
End If
End With
End Sub
?
總結
以上是生活随笔為你收集整理的批量word删除页眉页脚——VBS脚本,在office宏中运行即可的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python调用vbs脚本_xShell
- 下一篇: java计算机毕业设计销售人员绩效管理系