Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-27-2015, 06:36 AM
kennethc kennethc is offline Find & replace footer text in a folder of Word 2010 documents Windows XP Find & replace footer text in a folder of Word 2010 documents Office 2003
Novice
Find & replace footer text in a folder of Word 2010 documents
 
Join Date: Sep 2010
Posts: 23
kennethc is on a distinguished road
Default Find & replace footer text in a folder of Word 2010 documents

Hi



I have a folder of Word 2010 documents and a lot of the documents have a 2 line footer, e.g.

A list of employees is open for inspection at our offices. This company does not accept service by electronic mail or facsimile.
This company is regulated by the Brewers Authority.

This 2 line footer needs to be replaced with a 3 line footer, e.g.

ABC Brewery is the trading name of ABC Brewery PLC, registered in England and Wales with company number ABC999.
A list of employees is open for inspection at our offices. This company does not accept service by electronic mail or facsimile.
This company is regulated by the Brewers Authority.

Can anyone recommend a program or code that can deal with this amount of text (over a number of lines) in multiple document footers?

Many thanks in advance.

Kenneth
Reply With Quote
  #2  
Old 03-27-2015, 07:30 AM
gmayor's Avatar
gmayor gmayor is offline Find & replace footer text in a folder of Word 2010 documents Windows 7 64bit Find & replace footer text in a folder of Word 2010 documents Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following macro used as a custom process with
should do this. Try it on one of the documents first. The code will not process the footer if the change has already been made.

Code:
Function NewFooter(oDoc As Document) As Boolean
Dim oSection As Section
Dim oFooter As HeaderFooter
Dim oRng As Range
Const strFind As String = "A list of employees is open for inspection at our offices."
Const strAddText As String = "ABC Brewery is the trading name of ABC Brewery PLC, registered in England and Wales with company number ABC999." & vbCr
    On Error GoTo err_Handler
    For Each oSection In oDoc.Sections
        For Each oFooter In oSection.Footers
            If oFooter.Exists Then
                Set oRng = oFooter.Range
                If InStr(1, oFooter.Range.Text, strAddText) = 0 Then
                    With oRng.Find
                        Do While .Execute(FindText:=strFind)
                            oRng.InsertBefore strAddText
                            Exit Do
                        Loop
                    End With
                End If
            End If
        Next oFooter
    Next oSection
    NewFooter = True
lbl_Exit:
    Exit Function
err_Handler:
    NewFooter = False
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 03-28-2015, 02:18 AM
kennethc kennethc is offline Find & replace footer text in a folder of Word 2010 documents Windows XP Find & replace footer text in a folder of Word 2010 documents Office 2003
Novice
Find & replace footer text in a folder of Word 2010 documents
 
Join Date: Sep 2010
Posts: 23
kennethc is on a distinguished road
Default

Hi Graham

Many thanks for your response, it's greatly appreciated.

You will have to forgive my ignorance but do I open a Word document, alt-11 and paste the code as it is, it doesn't appear as a macro? And how will it know which folder of documents it needs to process?

As I say, forgive my ignorance.

Kenneth
Reply With Quote
  #4  
Old 03-28-2015, 02:49 AM
gmayor's Avatar
gmayor gmayor is offline Find & replace footer text in a folder of Word 2010 documents Windows 7 64bit Find & replace footer text in a folder of Word 2010 documents Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The macro is a function intended to be used as a custom process with the linked add-in, which handles the folders. You select the folder(s) from the add-in.

As for the code listing. This is installed in the normal template - see http://www.gmayor.com/installing_macro.htm

You can then enter its name 'NewFooter' in the Custom Process dialog of the add-in. See my web page linked in the previous post for more details.

You can use it with the current document; a folder full of documents; or a folder full of documents and all its sub folders.

It works by examining all the footer ranges in the document(s) to check for the replacement text, and the original text. If the original text is present and the replacement text is not, then the replacement is added to the original as you requested.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find & replace footer text in a folder of Word 2010 documents Find & Replace in Header/Footer in 1000 files amodiammmuneerk@glenmarkp Word 12 03-05-2018 03:31 AM
Find & replace footer text in a folder of Word 2010 documents Created VBA to Find and Replace in Body, Header and Footer with Highlighting the replacement text QA_Compliance_Advisor Word VBA 11 09-23-2014 04:40 AM
Find & replace footer text in a folder of Word 2010 documents How do I find/replace the same word in multiple documents? Ineedhelp! Word 3 03-04-2014 03:50 PM
Find & replace footer text in a folder of Word 2010 documents Find & Replace in Header/Footer PReinie Word 6 01-22-2014 06:45 PM
Footer Find & Replace Operation? binar Word 1 02-05-2013 10:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:31 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft