为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

批量删除Word文档页眉或页脚的方法

2017-09-21 5页 doc 19KB 98阅读

用户头像

is_842972

暂无简介

举报
批量删除Word文档页眉或页脚的方法批量删除Word文档页眉或页脚的方法 绝对可用批量删除word页眉页脚方法 1、首先创建2个宏 在word里面,点工具--宏--录制新宏--把名字„Macro1?改为„批量删除页脚?和„Macro2?改为„批量删除页脚?--点确定 2、然后点工具--宏--停止录制 3、点工具--宏--宏 4、选择„批量删除页脚?——点编辑 将下面代码黏贴到出现的页面 Sub批量删除页脚() Application.ScreenUpdating = False Dim MyPath As String, i As Inte...
批量删除Word文档页眉或页脚的方法
批量删除Word文档页眉或页脚的 绝对可用批量删除word页眉页脚方法 1、首先创建2个宏 在word里面,点工具--宏--录制新宏--把名字„Macro1?改为„批量删除页脚?和„Macro2?改为„批量删除页脚?--点确定 2、然后点工具--宏--停止录制 3、点工具--宏--宏 4、选择„批量删除页脚?——点编辑 将下面代码黏贴到出现的页面 Sub批量删除页脚() 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 Documents.Open(FileName:=.FoundFiles(i)) Set myDoc = ' 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 .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 ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Selection.Sections(1).Footers(1).PageNumbers.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 同上1-4步骤创建批量删除页眉,代码如下 Sub 批量删除页眉() 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", 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 5、到此宏创建成功 然后开始批量删除页眉页脚 6、点工具--宏--宏 7、选中批量删除,点运行 8、选中你要批量处理的文档即可
/
本文档为【批量删除Word文档页眉或页脚的方法】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索