有很多人剛接觸WORD的新手,經常會碰到的問題就是如何刪除頁眉頁腳,當然一個Word里面刪除頁眉頁腳不難,但有幾百多個Word里面都有頁眉頁腳要你刪除,那就難到不少人了,下面將針對這一問題,看看我是怎么操縱宏批量刪除多個Word頁眉頁腳,我獻丑了
假如我手上有500個word文檔需要刪除頁眉頁腳
先把需要刪除頁眉頁腳的500個word文檔放在一個文件夾下,然后打開此中一個文檔
在打開的文檔中,選擇在“東西”菜單中選擇“宏”--“宏”
隨后彈出“宏”對話框,在宏名中輸入"Application",最后點擊"建立"按鈕
隨后彈出“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 .Exeen
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.ActivveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.WholeStory
With Selection.ParagraphFormat
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
With .Borders
.DistanceFromTop = 1
.DistanceFromLeft = 4
.DistanceFromBottom = 1
.DistanceFromRight = 4
.Shadow = False
End With
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth075pt
.DefaultBorderColor = wdColorAutomatic
End With
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
geNumbers.Add PageNumberAlignment:= _
wdAlignPageNumberRight, FirstPage:=True
' 以上可以換當作是你本身錄制的宏
' C公共部門的代碼
Application.DisplayAlerts = False '強制執行“是”
'ActiveDocument.Saved = True'強制執行“否”
ActiveDocument.Close '退出
Next
End If
End With
Application.ScreenUpdating = True
MsgBox "所選Word文檔的頁眉頁腳已刪除!!!", 64, "☆★批量處置完畢★☆"
End Sub
Sub ConvertEqns()
'
' ConvertEqns Macro
' 宏在 2014-6-25 由 USER 建立
'
End Sub
輸入代碼后,封閉窗口返回文檔,從頭選擇在“東西”菜單中選擇“宏”--“宏”,在彈出的宏名中選擇"批量刪除Word頁眉頁腳",最后點擊“運行”---確認即可快速地刪除500個Word頁眉頁腳
0 篇文章
如果覺得我的文章對您有用,請隨意打賞。你的支持將鼓勵我繼續創作!