MS Word Headers-Footers

D

DGaskin

Using MS Word 2007: In selecting file names as part of the header, how do I
create automatic updates for that field (filename) so that if I change the
name of the file (while it is closed), it will automatically reflect the
update in the header the next time the file is opened?
 
D

Doug Robbins - Word MVP

You would need an autoopen macro in an add-in that updated the fields in the
..Range of the header.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

DGaskin

Any resource that you could suggest that I could use to build an "autoopen
macro"? Or is it something that is already available in an existing add-in?

-David
 
D

Doug Robbins - Word MVP

The following is the code that you would need:

Sub autoopen()
Dim i As Long, j As Long
With ActiveDocument
For i = 1 To .Sections.Count
With .Sections(i)
For j = 1 To .Headers.Count
.Headers(j).Range.Fields.Update
Next j
End With
Next i
End With
End Sub

See the article "What do I do with macros sent to me by other newsgroup
readers to help me out?" at:

http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

The macro should be stored in the Normal.Dot template
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
Top