Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-07-2012, 09:45 AM
patidallas22 patidallas22 is offline Word Macro - change date in footer for all files in a folder Windows XP Word Macro - change date in footer for all files in a folder Office 2007
Novice
Word Macro - change date in footer for all files in a folder
 
Join Date: Mar 2012
Posts: 12
patidallas22 is on a distinguished road
Default Word Macro - change date in footer for all files in a folder


I am trying to change the date in the footer for all the files in a specific folder and put in the following macro, but I must have done something wrong because it is not working. Our drive on our server is "W" but I don't know what I have input incorrectly. I saved my macro as "ReplaceDateFooter". Thanks for your help!

Code:
Sub ReplaceDateFooter()
Const D = "W:\PublicWorks\Projects\COF_City_of_Ft_Worth\Specs to play with"
Const Find = "July 1, 2011"
Const Replace = "March 1, 2012"
Dim doc As Document
Dim wd As New Word.Application
Dim fn As String
Dim rng As Range
Dim hf As HeaderFooter
Dim s As Section
fn = Dir(D & "*.doc")
While fn <> ""
  Set doc = wd.Documents.Open(D & fn)
  Debug.Print fn
  For Each s In doc.Sections
    For Each hf In s.Footers
      Set rng = hf.Range
      With rng.Find
        .Text = Find
        .Replacement.Text = Replace
        .Execute Replace:=wdReplaceAll
      End With
    Next
  Next
  doc.Save
  doc.Close
  fn = Dir
Wend
wd.Quit
End Sub

Last edited by macropod; 03-08-2012 at 10:10 PM. Reason: Added code structure & tags
Reply With Quote
 

Tags
change date, macro, vba word

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word macro doesn't change font color Spideriffic Word VBA 8 11-04-2015 03:47 AM
Word Macro - change date in footer for all files in a folder Change Footer style msm6165 PowerPoint 1 07-17-2011 03:40 PM
Word Macro - change date in footer for all files in a folder Auto Change Date in Word Document??? dssxxxx Word 2 01-06-2011 05:50 AM
Cannot stop the date being printed in the footer Ubtree Outlook 0 10-13-2007 11:49 AM
Word Macro - change date in footer for all files in a folder Imported message date change to today's date promark Outlook 1 12-23-2005 07:21 AM

Other Forums: Access Forums

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


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