You can fix all your existing documents in a folder by running the following
macro, which will replace DATE field with CREATEDATE fields
Change the switch in the line sSwitch = " \@ ""d MMMM yyyy""" to your local
requirement. This switch is required as Createdate fields may not display
the same format as date fields. Any existing switches are retained.
Sub BatchFixDates()
Dim strFile As String
Dim strPath As String
Dim sSwitch As String
Dim strDoc As Document
Dim iFld As Integer
Dim fDialog As FileDialog
sSwitch = " \@ ""d MMMM yyyy"""
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , "List Folder Contents"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
strFile = Dir$(strPath & "*.do?")
While strFile <> ""
Set strDoc = Documents.Open(strPath & strFile)
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
Select Case .Type
Case Is = wdFieldDate
.Code.Text = Replace(UCase(.Code.Text), _
"DATE", "CREATEDATE")
If InStr(1, .Code, "\@") = 0 Then
.Code.Text = .Code.Text & sSwitch
End If
.Update
Case Else
End Select
End With
Next iFld
strDoc.Close SaveChanges:=wdSaveChanges
strFile = Dir$()
Wend
End Sub
http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>