Change Footers 1300+ Docs

B

Benjamin

I need to programatically clean a large load of files.
I need to remove the Date Field from the Footers.
But I need to keep the File Name and Page Numbering
and not effect anything else but this Printed Text and Date Field.
I'm pretty familiar with Excel VBA. Can someone help get me started or give
me some code to get started with here.

Really appreciate it!

Examples of Footers below:

File: ESOP-201-SLF.doc Page 1 of 5
Printed: November 23, 2009 (remove this Printed & Date Field)

File: ESOP-509-MP Page 1 of 13
Printed: November 23, 2009

November 23, 2009
ECONTENT-PL2
 
D

Doug Robbins - Word MVP

See the following page of fellow MVP Graham Mayor's Website:

http://www.gmayor.com/batch_replace.htm

Rather than using the Replace function, assuming that the dates are
displayed by the use of one of the other Date fields (SaveDate, PrintDate,
CreateDate), you might want to use code to iterate through the fields in the
footers of the documents and and if the .Type of field is one of the Date
field types, set a range object to the .Code of the field (which is itself a
..Range) and then use .Range.Paragraphs(1).Range.Delete

The following code is probably want you would want

Dim i As Long, j As Long
Dim frange As Range, fcode As Range
With ActiveDocument
For i = 1 To .Sections.Count
With .Sections(i)
For j = 1 To .Footers.Count
Set frange = .Footers(j).Range
For k = frange.Fields.Count To 1 Step -1
Set fcode = frange.Fields(k).Code
If InStr(UCase(fcode.Text), "DATE") > 0 Then
fcode.Paragraphs(1).Range.Delete
End If
Next k
Next j
End With
Next i
End With


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top