View Single Post
 
Old 04-30-2019, 09:01 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,103
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

While my friend Greg Maxey and I have similar initials, we are not the same person and it is he who is 'Greg'.

The macro Doug supplied is not compatible with the add-in process as even if it was, the macro runs before the document filename is created and thus before it is saved so it cannot reflect the name of that document in its footer.

If the aim is to add the filename to the footer then you can get the name of the document (not the PDF file) with

Code:
Sub FooterTx(oDoc As Document)
Dim i As Long
Dim fname As Range
    With oDoc
        Set fname = .Sections(1).Footers(wdHeaderFooterPrimary).Range
        fname.End = fname.End - 1
        fname.Collapse 0
        fname.Fields.Add fname, wdFieldFileName, " \p", False
    End With
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote