Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2014, 09:30 PM
amodiammmuneerk@glenmarkp amodiammmuneerk@glenmarkp is offline Find & Replace in Header/Footer in 1000 files Windows 7 32bit Find & Replace in Header/Footer in 1000 files Office 2013
Novice
Find & Replace in Header/Footer in 1000 files
 
Join Date: Jan 2014
Posts: 5
amodiammmuneerk@glenmarkp is on a distinguished road
Default Find & Replace in Header/Footer in 1000 files

Hi,

I have 1000 odd word files in which I want to replace Header & Footer text, is there an automate way to achieve this.
is there any Microsoft or any third party tool available to address this ask,



Thanks & Regards
Amodiamm
Reply With Quote
  #2  
Old 01-22-2014, 03:32 PM
macropod's Avatar
macropod macropod is offline Find & Replace in Header/Footer in 1000 files Windows 7 32bit Find & Replace in Header/Footer in 1000 files Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

This can be done quite easily via a macro. For example, the following macro allows you to browse to a folder containing the documents you want to process, then replace a given string in all documents in that folder automatically.
Code:
Sub UpdateDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document, Sctn As Section, HdFt As HeaderFooter
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdDoc
    For Each Sctn In .Sections
      For Each HdFt In Sctn.Headers
        If HdFt.LinkToPrevious = False Then
          With HdFt.Range.Find
            .ClearFormatting
            .Text = "Old Header Text"
            .Replacement.Text = "New Header Text"
            .Forward = True
            .Wrap = wdFindStop
            .Format = False
            .MatchCase = True
            .MatchWholeWord = True
            .MatchWildcards = False
            .Execute Replace:=wdReplaceAll
          End With
        End If
      Next
      For Each HdFt In Sctn.Footers
        If HdFt.LinkToPrevious = False Then
          With HdFt.Range.Find
            .ClearFormatting
            .Text = "Old Footer Text"
            .Replacement.Text = "New Footer Text"
            .Forward = True
            .Wrap = wdFindStop
            .Format = False
            .MatchCase = True
            .MatchWholeWord = True
            .MatchWildcards = False
            .Execute Replace:=wdReplaceAll
          End With
        End If
      Next
    Next
    .Close SaveChanges:=True
  End With
  strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
For macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-23-2014, 10:49 PM
MD_Sari MD_Sari is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 64bit Find &amp; Replace in Header/Footer in 1000 files Office 2003
Novice
 
Join Date: Jan 2014
Posts: 2
MD_Sari is on a distinguished road
Default

Hi Paul,

Appreciate for the macro code

While using this macro it changes only one and the recent document header in the folder browsed..
kindly note that we have office 2003 documents.

Any help is appreciated...

Regards.
MD Sari
Reply With Quote
  #4  
Old 01-24-2014, 12:28 AM
fumei fumei is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 64bit Find &amp; Replace in Header/Footer in 1000 files Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

It changes only one what? One header? One file? What do you mean by "recent document header"?
Reply With Quote
  #5  
Old 01-24-2014, 07:09 AM
MD_Sari MD_Sari is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 64bit Find &amp; Replace in Header/Footer in 1000 files Office 2003
Novice
 
Join Date: Jan 2014
Posts: 2
MD_Sari is on a distinguished road
Default

It changes header in only one file among the multiple .doc files available in the folder
Reply With Quote
  #6  
Old 01-24-2014, 07:22 AM
gmaxey gmaxey is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 32bit Find &amp; Replace in Header/Footer in 1000 files Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default Add-In

Have you looked at or tried: http://gregmaxey.com/word_tip_pages/...d_replace.html
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #7  
Old 01-24-2014, 03:05 PM
macropod's Avatar
macropod macropod is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 32bit Find &amp; Replace in Header/Footer in 1000 files Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by MD_Sari View Post
While using this macro it changes only one and the recent document header in the folder browsed
That strongly suggests the headers in the other files don't contain exactly the same content as whatever you've input as the 'Old Header Text'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 01-24-2014, 03:57 PM
fumei fumei is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 64bit Find &amp; Replace in Header/Footer in 1000 files Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Definitely. MD Sari, the code works as stated. If you are not getting the results you want then there is something different with your files.
Reply With Quote
  #9  
Old 03-05-2018, 02:24 AM
amanza amanza is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 64bit Find &amp; Replace in Header/Footer in 1000 files Office 2010 64bit
Novice
 
Join Date: Mar 2018
Posts: 3
amanza is on a distinguished road
Default

hi i'm new here. I was also trying to find the same and stumble here, and I am aware that this is an old thread but. I am using MS Word 2010 and as have mentioned it only works on the first word file. Currently because it does find and replace footer and header my only solution is to folder each file and run the macro to each folder as this is still fast than opening each file. @macropod is there anyway you can modify the code? thanks in advance.
Reply With Quote
  #10  
Old 03-05-2018, 02:27 AM
macropod's Avatar
macropod macropod is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 64bit Find &amp; Replace in Header/Footer in 1000 files Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The code is post #2 will work on as many documents as your folder contains.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 03-05-2018, 02:51 AM
amanza amanza is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 64bit Find &amp; Replace in Header/Footer in 1000 files Office 2010 64bit
Novice
 
Join Date: Mar 2018
Posts: 3
amanza is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
The code is post #2 will work on as many documents as your folder contains.
Thanks Paul, the reason it is not working is because my footer was done as Table? Would this macro run successfully on tabled-style header & footer?
Reply With Quote
  #12  
Old 03-05-2018, 02:53 AM
macropod's Avatar
macropod macropod is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 64bit Find &amp; Replace in Header/Footer in 1000 files Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It makes no difference to the code whether the header/footer content is in a table - unless someone has gone and put that table in a textbox or a frame.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 03-05-2018, 03:31 AM
amanza amanza is offline Find &amp; Replace in Header/Footer in 1000 files Windows 7 64bit Find &amp; Replace in Header/Footer in 1000 files Office 2010 64bit
Novice
 
Join Date: Mar 2018
Posts: 3
amanza is on a distinguished road
Default

I do not know how the footer is but i know it is a table. Though your code still usable for me and thank you.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find &amp; Replace in Header/Footer in 1000 files 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
Find &amp; Replace in Header/Footer in 1000 files Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
Find &amp; Replace in Header/Footer in 1000 files header & footer avi_sai Word 1 12-03-2011 10:52 AM
Find &amp; Replace in Header/Footer in 1000 files Help with find and replace or query and replace shabbaranks Excel 4 03-19-2011 08:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:53 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