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

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

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

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. Jay Freedman
    Replies:
    1
    Views:
    360
    Klaus Linke
    Sep 30, 2003
  2. Joe

    Show last folder not full path

    Joe, Dec 29, 2003, in forum: Word VBA Beginners
    Replies:
    3
    Views:
    85
    Jay Freedman
    Dec 30, 2003
  3. ben

    VBA, VBS and Network Security Issues in IE

    ben, Apr 19, 2004, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    71
  4. Christopher Andrews

    Use VBA to map network drive

    Christopher Andrews, Jan 17, 2005, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    576
    Word Heretic
    Jan 22, 2005
  5. Hezviz

    Changing the default Pictures Path in Word

    Hezviz, Jan 30, 2005, in forum: Word VBA Beginners
    Replies:
    7
    Views:
    151
    Hezviz
    Feb 5, 2005
  6. Thomas Lindberg
    Replies:
    0
    Views:
    212
    Thomas Lindberg
    Nov 21, 2005
  7. Roger Marrs

    path to remote server in VBA

    Roger Marrs, Jan 9, 2006, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    104
    Roger Marrs
    Jan 10, 2006
  8. Eric van der Niet

    SharePoint and Word Startup path

    Eric van der Niet, Sep 25, 2007, in forum: Word VBA Beginners
    Replies:
    0
    Views:
    98
    Eric van der Niet
    Sep 25, 2007
Loading...