Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Our Records department just asked me how to change the date field in Word documents to a static date reflecting the date the document was created. Apparently, some administrative staff inserted date fields instead of static dates on all their documents. Now, 5-10 years later, we need to be able to print those documents with the original creation date, not have it change to the current date.

    Sure, we can open each one, delete the date field and type the creation date. But, we thousands of these documents in several folders.

    As you all know, I am code illiterate. But, I was wondering if one of you clever souls knows how to write code that would go through a folder, find all the Word documents that use the date field, replace the date field with the original creation date and also write a comment to the document properties stating that the document was modified to replace the field with a static date (so the records auditor doesn't look at the file properties and think we modified the document).

    Or do you have another suggestion? Has anyone else had this issue and found a cool solution?

    We are doing this to comply with Public Records regulations. Sigh.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could replace the DATE field with the CREATEDATE field:

    Code:
    Sub ReplaceDate()
      Dim rng As Range
      Dim fld As Field
      For Each rng In ActiveDocument.StoryRanges
    	For Each fld In rng.Fields
    	  If fld.Type = wdFieldDate Then
    		fld.Code.Text = Replace(fld.Code.Text, "DATE", "CREATEDATE")
    	  End If
    	Next fld
    	Do While Not rng.NextStoryRange Is Nothing
    	  Set rng = rng.NextStoryRange
    	  For Each fld In rng.Fields
    		If fld.Type = wdFieldDate Then
    		  fld.Code.Text = Replace(fld.Code.Text, "DATE", "CREATEDATE")
    		End If
    	  Next fld
    	Loop
      Next rng
    End Sub

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, Hans. Where would I put this code? In a new Word doc and make it a macro?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If you copy it into a module in Normal.dot, you can run it in any document.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •