Hello,

I need to create a macro in Word 2010, that will add a footer to documents with the file name, without the extension.

I found a code that displays the file name without the extension when you use a docvariable field:

Sub autofilenamefooter()

Dim fname As String
fname = ActiveDocument.Name
fname = Left(fname, InStr(fname, ".") - 1)

With ActiveDocument

.Variables("fname").Value = fname

.PrintPreview
.ClosePrintPreview

End With

End Sub


How can I use this to create a macro that:

1. Foots the document with the file name before printing (so that the field will be updated each time you print the document).

2. In addition, the new footer (with the file name) will not delete existing footers, if any. This requirement is due to the fact that the macro should be applied to all documents in our document management system, and some of the documents already have footers (such as firm papers with logos) that I would like to keep.

Thanks in advance!