D
David Bassett
My users want the name of the document file to appear in
the header whenever they save the document. The problem
I have is whenever they re-save the document. The code
would add a second instance of the filename date field.
The code I have now completely fails to put the date
field in at all. I need for the code to not add but
update or delete and reinsert the file name whenever the
users save.
Sub FileSave()
ActiveDocument.Save
Dim myrange As Range
Dim aField As Field
Set myrange = ActiveDocument.Sections(1).Footers _
(wdHeaderFooterPrimary).Range
For Each aField In myrange.Fields
aField.Delete
Next aField
Dim myrange1 As Range
Set myrange1 = ActiveDocument.Bookmarks
("FooterFileName").Range
With myrange1
.Fields.Add Range:=myrange, Type:=wdFieldFileName
End With
End Sub
TIA!
david
the header whenever they save the document. The problem
I have is whenever they re-save the document. The code
would add a second instance of the filename date field.
The code I have now completely fails to put the date
field in at all. I need for the code to not add but
update or delete and reinsert the file name whenever the
users save.
Sub FileSave()
ActiveDocument.Save
Dim myrange As Range
Dim aField As Field
Set myrange = ActiveDocument.Sections(1).Footers _
(wdHeaderFooterPrimary).Range
For Each aField In myrange.Fields
aField.Delete
Next aField
Dim myrange1 As Range
Set myrange1 = ActiveDocument.Bookmarks
("FooterFileName").Range
With myrange1
.Fields.Add Range:=myrange, Type:=wdFieldFileName
End With
End Sub
TIA!
david