Word基本技巧

有很多人刚接触WORD的新手,经常会碰到的问题就是如何删除页眉页脚,当然一个Word里面删除页眉页脚不难,但有几百多个Word里面都有页眉页脚要你删除,那就难到不少人了,下面将针对这一问题,看看我是怎么操纵宏批量删除多个Word页眉页脚,我献丑了

东西/原料

  • 运行情况WinXP/Vista/Win7/Win8
  • Word2003

方式/步调

  1. 1

    假如我手上有500个word文档需要删除页眉页脚

  2. 2

    先把需要删除页眉页脚的500个word文档放在一个文件夹下,然后打开此中一个文档

  3. 3

    在打开的文档中,选择在“东西”菜单中选择“宏”--“宏”

  4. 4

    随后弹出“宏”对话框,在宏名中输入"Application",最后点击"建立"按钮

  5. 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 .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

  6. 6

    输入代码后,封闭窗口返回文档,从头选择在“东西”菜单中选择“宏”--“宏”,在弹出的宏名中选择"批量删除Word页眉页脚",最后点击“运行”---确认即可快速地删除500个Word页眉页脚

  • 发表于 2019-11-12 20:00
  • 阅读 ( 787 )
  • 分类:其他类型

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
联系我们:uytrv@hotmail.com 问答工具