批量word删除页眉页脚——VBS脚本,在office宏中运行即可
批量word刪除頁(yè)眉頁(yè)腳——VBS腳本,在office宏中運(yùn)行即可?
Sub 批量刪除頁(yè)眉頁(yè)腳()
'此代碼功能為列出指定文件夾中所有選取的WORD文件全路徑名
Dim myDialog As FileDialog, oDoc As Document, oSec As Section
Dim oFile As Variant, myRange As Range
On Error Resume Next
'定義一個(gè)文件夾選取對(duì)話框
Set myDialog = Application.FileDialog(msoFileDialogFilePicker)
With myDialog
.Filters.Clear '清除所有文件篩選器中的項(xiàng)目
.Filters.Add "所有Word文件", "*.doc,*.docx", 1 '增加篩選器的項(xiàng)目為所有Word文件
.AllowMultiSelect = True '允許多項(xiàng)選擇
If .Show = -1 Then '確定
For Each oFile In .SelectedItems '在所有選取項(xiàng)目中循環(huán)
Set oDoc = Word.Documents.Open(FileName:=oFile, Visible:=False)
For Each oSec In oDoc.Sections '文檔的節(jié)中循環(huán)
Set myRange = oSec.Headers(wdHeaderFooterPrimary).Range
myRange.Delete '刪除頁(yè)眉中的內(nèi)容
myRange.ParagraphFormat.Borders(wdBorderBottom).LineStyle = wdLineStyleNone '段落下邊框線
Set myRange = oSec.Footers(wdHeaderFooterPrimary).Range
myRange.Delete '刪除頁(yè)腳中的內(nèi)容
Next
oDoc.Close True
Next
End If
End With
End Sub
?
總結(jié)
以上是生活随笔為你收集整理的批量word删除页眉页脚——VBS脚本,在office宏中运行即可的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python调用vbs脚本_xShell
- 下一篇: 影楼修片走下神坛 PS磨皮技巧大揭秘