How do I Find and replace date fields?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a doc in which date fields were used to indicate when the item /text
was added to the document. I want to find all the date fields and delete
them, without deleting the fields for figures/table and table of contents,
etc... I know I can use Find to find all the fields but I just want to find
and replace / delete the Date Fields.
Thanks,
MK
 
Provided the fields are in the main text story then this should do:

Sub ScratchMacro2()
Dim oFld As Word.Field
For Each oFld In ActiveDocument.Range.Fields
Select Case oFld.Type
Case Is = wdFieldDate, wdFieldCreateDate, wdFieldSaveDate,
wdFieldPrintDate
oFld.Delete
Case Else
'Do Nothing
End Select
Next oFld
End Sub

If you need to iterate through all storyranges (e.g., headers,
footers, etc) then adapt the code shown here:

http://gregmaxey.mvps.org/Field_Macros.htm
 
Of course you could just use:

^ d Date

in the find what and replace with nothing

repeat with the other date field types.
 
Thanks Greg,
One minor point to Find Date Fields they need to be visible "Show Fields"
Alt+F9 will show all field codes then the find and replace works great.

Thanks again.
 
Back
Top