How to find full network path in Word VBA

Discussion in 'Word VBA Beginners' started by Paul Cox, Dec 8, 2003.

  1. Paul Cox

    Paul Cox Guest

    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
     
    Paul Cox, Dec 8, 2003
    #1
    1. Advertising

  2. 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, "\")

    --
    Regards
    Jonathan West - Word MVP
    http://www.multilinker.com
    Please reply to the newsgroup


    "Paul Cox" <> wrote in message
    news:br228v$l4o$07$-online.com...
    > 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
    >
     
    Jonathan West, Dec 8, 2003
    #2
    1. Advertising

  3. Paul Cox

    Paul Cox Guest

    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?

    Jonathan West wrote:
    > 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, "\")
    >
     
    Paul Cox, Dec 8, 2003
    #3
  4. Ah, for that, use the ActiveDocument.FullName property

    --
    Regards
    Jonathan West - Word MVP
    http://www.multilinker.com
    Please reply to the newsgroup

    "Paul Cox" <> wrote in message
    news:br2em3$a6q$06$-online.com...
    > 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?
    >
    > Jonathan West wrote:
    > > 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, "\")
    > >

    >
     
    Jonathan West, Dec 8, 2003
    #4
  5. Paul Cox

    Paul Cox Guest

    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?


    Jonathan West wrote:
    > Ah, for that, use the ActiveDocument.FullName property
    >
     
    Paul Cox, Dec 9, 2003
    #5
  6. 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)

    --
    Regards
    Jonathan West - Word MVP
    http://www.multilinker.com
    Please reply to the newsgroup


    "Paul Cox" <> wrote in message
    news:br47nn$hhk$02$-online.com...
    > 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?
    >
    >
    > Jonathan West wrote:
    > > Ah, for that, use the ActiveDocument.FullName property
    > >

    >
     
    Jonathan West, Dec 9, 2003
    #6
  7. Paul Cox

    Paul Cox Guest

    A solution is also available at:
    http://www.mvps.org/access/api/api0009.htm
    This successfully produces the characters of the computer name.
    --------------

    Jonathan West wrote:
    > 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)
    >
     
    Paul Cox, Dec 9, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. troubledHC
    Replies:
    1
    Views:
    98
    Brendan Reynolds
    Jun 14, 2005
  2. Author
    Replies:
    4
    Views:
    96
    Klatuu
    Aug 28, 2008
  3. Barry Nielsen
    Replies:
    2
    Views:
    87
    Barry Nielsen
    Nov 21, 2007
  4. Replies:
    3
    Views:
    56
    Ivan Raiminius
    May 19, 2006
  5. Replies:
    0
    Views:
    75
Loading...

Share This Page