Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

How to return UNC pathnames

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
karina thomas - 08 Nov 2004 18:29 GMT
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!
DA - 08 Nov 2004 23:47 GMT
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
[quoted text clipped - 9 lines]
>Thanks!
>.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.