How to find full network path in Word VBA

P

Paul Cox

I'd like to find out the start of the path, for example
"\\Mycomputer\c\folder\etc ..."
so I can see the "Mycomputer" name.

Is there a shortcut here?
Thanks for a response.
Paul
 
J

Jonathan West

If the full path is in a variable (maybe called fullpath), then the first
part of the path can be found using this function

FirstPart = Left$(FullPath, Instr(3, FullPath, "\")
 
P

Paul Cox

Thank you for your reply.
I understand the need to extract the characters from the string.

I think the problem is to find that "fullpath" variable.
If I use the code "ActiveDocument.Name" I get the path starting with
drive letter but not the computer name.

Is a built-in code in Word VBA which will give the full path?
 
P

Paul Cox

On my machine a message box to show the property
ActiveDocument.FullName property
only gives something like
"C:\myfiles\thisdocument.doc"

For me this is the local path and not the full
network path to the document.

What I am looking for is the information
"\\ComputerName\C\myfiles\thisdocument.doc"
so that then I can extract the information
"\\ComputerName".

Is there a simple way to get this network path
to the document?
 
J

Jonathan West

Hi Paul,

If the file is stored on a local drive, then as far as I know there isn't an
automatic way of getting the computer & sharename, you'll have to do the
replacement yourself, knowing what shares are available.

If the file is on a network drive which happens to be mapped to a drive
letter, then you can get the full UNC pathname this way

UNCName = WordBasic.FileNameInfo$(ActiveDocument.FullName, 6)
 

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