Template question

  • Thread starter Thread starter Ross Moody
  • Start date Start date
R

Ross Moody

I have a large number of archived letters that I wrote with the aid of a
word template. Each time I open them for reference, word automatically
updates the archived letter to the current date. I prefer to leave the
original date unchanged. How can I do this but not destroy the templates
attributes for newly developed letters? Thanks. Ross
 
In the template, change the DATE field to CREATEDATE. Do the same in the
existing letters. Press Alt+F9 to view the field code, type CREATE in front
of DATE, Alt+F9 to toggle back, and F9 to update.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
Replace the inserted DATE field with a CREATEDATE field: Open each of the
documents. Press Alt+F9 to show field codes. Just type in CREATEDATE instead
of DATE. Press F9. Press Alt+F9 again to hide field codes.

Also, make sure to change the field in the template (for future documents).
 
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

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top