How can I automatically add document title at end of document?

  • Thread starter Thread starter teknon
  • Start date Start date
T

teknon

I use to use Corel. After naming a document, I could automatically add the
document name at the end of a document. I remember that it was different
than an endnote.
 
You can use the filename field, adding the \p switch if you also want the
path.

One way to do this is to press Ctrl+F9, type filename (or filename \p), then
press F9.

Another way is to choose Insert tab, Quick Parts, Field, select FileName
(tick Add path to filename if desired), and click OK. (This presumes Word
2007... if you're using Word 2003 or earlier, then choose Insert - Field,
instead).

--

Herb Tyson MS MVP
Author of the Word 2007 Bible
Blog: http://word2007bible.herbtyson.com
Web: http://www.herbtyson.com
 
The following macro will both save the document and insert the filename and
path at the end. If you want just the name change the instances of .Fullname
to .Name. If you change the name of the document or the file location,
re-run the macro.

Sub InsertFileNameAtEnd()
With ActiveDocument
If Len(.Path) = 0 Then .Save
If InStr(1, .Range.Paragraphs.Last.Range.Text, _
".doc") = False Then
.Range.InsertAfter vbCr & .FullName
With .Range.Paragraphs.Last.Range
.Paragraphs.Alignment = _
wdAlignParagraphRight
.Font.name = "Arial"
.Font.Size = 8
End With
Else
.Range.Paragraphs.Last.Range.Text = _
.FullName
End If
End With
End Sub

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

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top