• Change date field to static date (2003)

    • This topic has 3 replies, 2 voices, and was last updated 16 years ago.
    Author
    Topic
    #459927

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #1161107

      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
      • #1161109

        Thank you, Hans. Where would I put this code? In a new Word doc and make it a macro?

        • #1161110

          If you copy it into a module in Normal.dot, you can run it in any document.

    Viewing 0 reply threads
    Reply To: Change date field to static date (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: