View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default How can I insert the file location path into a Word doc?

Do you want just the filepath or the filepath and docname?
If the former then the following macro will do that:

Sub InsertPath()
Dim pPathname As String
Dim pFoldername As String
With ActiveDocument
If Not .Saved Then
.Save
End If
pPathname = Left$(.FullName, (Len(.FullName) - Len(.Name) - 1))
pFoldername = Right$(pPathname, (Len(pPathname) -
InStrRev(pPathname, "\")))
End With
Selection.TypeText pPathname
End Sub

If you want the latter, use a filename field with a \p switch (there should
be an autotext entry to do this)
or if you prefer the macro approach

Sub InsertFileNameAndPath()
Dim fFname As String
With ActiveDocument
If Not .Saved Then
.Save
End If
fFname = .FullName
End With
Selection.TypeText fFname
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


tanqueverde wrote:
I have Office 2000 and I can't find a way to insert the file path
into a Word document. The properties window won't let me copy the
file location information. I'd like a fast way to copy the file
location path into some of my documents prior to printing.