How can I insert the file location path into a Word doc?

G

Guest

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.
 
G

Graham Mayor

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

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

Do the following:

1. Click View->Header Footer
2. Click Insert AutoText
3. Click Filename and Path
4. Select All
5. Click Edit->Copy
6. Click Edit-> Paste in the document

Challa Prabhu
 
S

Suzanne S. Barnhill

Insert | Field: FileName. If you want the full path, add the \p switch. Or
select the "Filename and path" AutoText entry from the Header/Footer
category.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top