Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Aug 2014
    Thanked 0 Times in 0 Posts

    Word Vba to copy files from old to new directory with deletion of headers & Footers

    Is it possible to prepare a VBA macro in word 2007 to make a new dir and copy all doc/docx files from another dir/sub dir , remove all headers and footers and convert all doc files ( if any) to docx

    If anyone can provide me a vba script it will be great.

    Thank You!!!

  2. #2
    Star Lounger Graham Mayor's Avatar
    Join Date
    Mar 2016
    Thanked 23 Times in 23 Posts
    The simplest solution is to copy the documents to the new folder then use which will convert the documents to DOCX, and, as a separate process, you could then use it with the following custom process to remove the headerfooters

    Function DelHeaderFooters(oDoc As Document) As Boolean
    Dim oSection As Section
    Dim oHeader As HeaderFooter
    Dim oFooter As HeaderFooter
        On Error GoTo err_handler
        For Each oSection In oDoc.Sections
            For Each oHeader In oSection.Headers
                If oHeader.Exists Then oHeader.Range.Delete
            Next oHeader
            For Each oFooter In oSection.Footers
                If oFooter.Exists Then oFooter.Range.Delete
            Next oFooter
        Next oSection
        DelHeaderFooters = True
        Exit Function
        DelHeaderFooters = False
        Resume lbl_Exit
    End Function
    Graham Mayor - Word MVP

  3. The Following User Says Thank You to Graham Mayor For This Useful Post:

    springler (2016-07-18)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts