Macropod,
I've done as you instructed, and this is the result:
Sub UpdateDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
Dim Sctn As Section, HdFt As HeaderFooter, Shp As Shape
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
With HdFt
If .LinkToPrevious = False Then
'Process the header
Call Update(.Range)
End If
End With
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
Sub Update(Rng As Range)
With Rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}"
.Replacement.Text = Format(Now, "M/D/YYYY")
.MatchWildcards = True
.Forward = True
.Wrap = wdFindStop
.Format = False
.Execute Replace:=wdReplaceAll
End With
End Sub
When I run the macro, it again produces a pop up window that allows me to select the folder I want, I press okay, and then anti-climatically... Nothing happens. No flickering screen of it running through all the documents, nada.
Any thoughts?
Thanks!