資源描述:
《怎么在word中批量刪除頁眉和頁腳.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、怎么在word中批量刪除頁眉和頁腳 在日常工作中,我們有時(shí)會(huì)碰到一大堆文件需要批量刪除頁眉與頁腳,如果一個(gè)個(gè)打開文件手工刪除的話,會(huì)很耗時(shí)間精力,下面小編就教你怎么在word中批量刪除頁眉和頁腳. word中批量刪除頁眉和頁腳的步驟: 首先,我先制作一個(gè)測試文件夾,里面包含幾個(gè)word文檔,都有頁眉--百度經(jīng)驗(yàn)這四個(gè)字,當(dāng)然其他的文字也行,只是一個(gè)測試; 下面我們需要打開宏,03版的宏不需要去開啟開發(fā)工具,只需要點(diǎn)擊菜單欄中的工具-宏-宏; 進(jìn)入宏對話框,我們可以在宏名隨便輸入英文字母,在右側(cè)點(diǎn)擊一下創(chuàng)建; 接著,進(jìn)入了宏代碼編寫框,將下
2、面代碼復(fù)制進(jìn)來: Sub批量刪除頁眉頁腳() Application.ScreenUpdating=False DimMyPathAsString,iAsInteger,myDocAsDocument WithApplication.FileDialog(msoFileDialogFolderPicker) .Title="選擇要處理目標(biāo)文件夾"&"——(刪除里面所有Word文檔的頁眉頁腳)" If.Show=-1Then MyPath=.SelectedItems(1) Else ExitSub EndIf EndWith
3、WithApplication.FileSearch .LookIn=MyPath .FileType=msoFileTypeWordDocuments If.Execute>0Then Fori=1To.FoundFiles.Count SetmyDoc=Documents.Open(FileName:=.FoundFiles(i)) 'B可以替換的宏 '以下是處理格式所錄制的宏,可根據(jù)所需錄制 IfActiveWindow.View.SplitSpecial<>wdPaneNoneThen ActiveWindow.Panes(
4、2).Close EndIf IfActiveWindow.ActivePane.View.Type=wdNormalViewOrActiveWindow._ ActivePane.View.Type=wdOutlineViewThen ActiveWindow.ActivePane.View.Type=wdPrintView EndIf ActiveWindow.ActivePane.View.SeekView=wdSeekCurrentPageHeader Selection.WholeStory Selection.Delete
5、Unit:=wdCharacter,Count:=1 Selection.WholeStory WithSelection.ParagraphFormat .Borders(wdBorderLeft).LineStyle=wdLineStyleNone .Borders(wdBorderRight).LineStyle=wdLineStyleNone .Borders(wdBorderTop).LineStyle=wdLineStyleNone .Borders(wdBorderBottom).LineStyle=wdLineStyleN
6、one With.Borders .DistanceFromTop=1 .DistanceFromLeft=4 .DistanceFromBottom=1 .DistanceFromRight=4 .Shadow=False EndWith EndWith WithOptions .DefaultBorderLineStyle=wdLineStyleSingle .DefaultBorderLineWidth=wdLineWidth075pt .DefaultBorderColor=wdColorAutomatic EndW
7、ith IfSelection.HeaderFooter.IsHeader=TrueThen ActiveWindow.ActivePane.View.SeekView=wdSeekCurrentPageFooter Else ActiveWindow.ActivePane.View.SeekView=wdSeekCurrentPageHeader EndIf Selection.WholeStory Selection.DeleteUnit:=wdCharacter,Count:=1 ActiveWindow.ActivePane.
8、View.SeekView=wdSeekMainDocument Selection.Sections(1