有許多人剛接觸WORD的新手,常常會遇到的問題就是怎樣刪除頁眉頁腳,當然一個Word里面刪除頁眉頁腳不難,但有幾百多個Word里面都有頁眉頁腳要你刪除,那就難到不少人了,下面將針對這一問題,看看我是怎么利用宏批量刪除多個Word頁眉頁腳,我獻丑了。
1、假如我手上有500個word文檔需要刪除頁眉頁腳
2、先把需要刪除頁眉頁腳的500個word文檔放在一個文件夾下,然后打開其中一個文檔
3、在打開的文檔中,選擇在“工具”菜單中選擇“宏”--“宏”
4、隨后彈出“宏”對話框,在宏名中輸入"Application",最后點擊"創建"按鈕
5、隨后彈出“Microsoft visual basic”設計,在編輯處輸入如下代碼
Sub 批量刪除Word頁眉頁腳()
Application.ScreenUpdating = False
Dim MyPath As String, i As Integer, myDoc As Document
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "選擇要處理目標文件夾" & "——(刪除里面所有Word文檔的頁眉頁腳)"
If .Show = -1 Then
MyPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
With Application.FileSearch
.LookIn = MyPath
.FileType = msoFileTypeWordDocuments
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Set myDoc = Documents.Open(FileName:=.FoundFiles(i))
' B可以替換的宏
' 以下是處理格式所錄制的宏,可根據所需錄制
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.WholeStory
With Selection.ParagraphFormat
新聞熱點
疑難解答