How to return UNC pathnames

K

karina thomas

We use the Filename \p (with path) field to return the filename and path in
footers. However, using the logical drive letter makes it very unmeaningful
to other 4000 users in the corporation! We'd like to have the path refer to
the UNC sharenames instead. Does anyone know of a way to either change a
setting in Windows XP or Word XP so the Filename field would return the UNC
instead of logical drive letter, or, alternatively, we could right code to
insert the filename and path if someone can point me to a line or two of VBA
code that would return the UNC (I tried ActiveDocument.Path and it just
returned the logical drive letter).

Thanks!
 
D

DA

Hi Karina

Unfortunately there's no inbuilt functionality within
field codes to return the UNC path, so you'll have to use
a VBA macro. Here's a function to return the required
info.

Set a reference to the "Microsoft Scripting Runtime"
library. Call this function from a SUB by supplying full
filename - for example:
testfileUNC = ReturnUNC("s:\shared\testdoc.doc")

-------------------------------------
Function ReturnUNC(strFileIn As String)

Dim strDrive
Dim strShare
Dim myfso As New Scripting.FileSystemObject

strDrive = myfso.GetDriveName(strFileIn)
strShare = myfso.Drives(strDrive).ShareName
ReturnUNC = strShare & _
Right(strFileIn, Len(strFileIn) - 2)

End Function
-------------------------------------

Hope this helps,
Dennis
-----Original Message-----
We use the Filename \p (with path) field to return the filename and path in
footers. However, using the logical drive letter makes it very unmeaningful
to other 4000 users in the corporation! We'd like to have the path refer to
the UNC sharenames instead. Does anyone know of a way to either change a
setting in Windows XP or Word XP so the Filename field would return the UNC
instead of logical drive letter, or, alternatively, we could right code to
insert the filename and path if someone can point me to a line or two of VBA
code that would return the UNC (I tried
ActiveDocument.Path and it just
 

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