![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]()
Hi patidallas,
One thing you'll need is a '\' on the end of your path; otherwise 'D & fn' simply appends the document name to the end of the path name. PS: When posting code, please use code tags (on the Advanced tab)
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]() ![]() Last edited by patidallas22; 03-09-2012 at 08:16 AM. Reason: Add smiley |
![]() |
Tags |
change date, macro, vba word |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word macro doesn't change font color | Spideriffic | Word VBA | 8 | 11-04-2015 03:47 AM |
![]() |
msm6165 | PowerPoint | 1 | 07-17-2011 03:40 PM |
![]() |
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 |
![]() |
promark | Outlook | 1 | 12-23-2005 07:21 AM |