Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Filepaths (WinNT, W97)

    A (hopefully) quick query - I need to find out, with VBA, which department a person using a template is in; since each department has a different template directory, I had the idea of ascertaining their department using this path, something along the lines of (and this is not working vba, just an approximation of what I thought might be possible):

    dim DriveT as (string?)
    if filepath("T:") = "serverdatatemplateman" then DriveT = "MAN"

    Could someone tell me if this is possible, and if I am looking in the right direction? I would be very grateful.
    Beryl M


  2. #2
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Filepaths (WinNT, W97)

    Extra comment - would there be any way of getting Word to pickup what the login name is that the user is logged in under? This might be another way of doing it, as our login names start with the department initials (ie I'm ITBM) ...

    Many thanks
    Beryl M


  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filepaths (WinNT, W97)

    You can get at the path to the user templates as follows:

    Options.DefaultFilePath(wdUserTemplatesPath)

    and to the workgroup templates as follows:

    Options.DefaultFilePath(wdWorkgroupTemplatesPath)

    <img src=/w3timages/blueline.gif width=33% height=2>

    The following will return the path of the template the active document is attached to:

    Dim strPath As String
    strPath = ActiveDocument.AttachedTemplate.Path

    <img src=/w3timages/blueline.gif width=33% height=2>

    On a network, you can use Windows API to get the name of the network user:

    Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" _
    (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long

    Function NetUser() As String
    Dim strName As String, strUserName As String, intPos As Integer
    strName = vbNullString
    strUserName = Space(25)
    If WNetGetUser(strName, strUserName, Len(strUserName)) = 0 Then
    intPos = InStr(strUserName, vbNullChar)
    NetUser = Left(strUserName, intPos - 1)
    Else
    NetUser = "unknown"
    End If
    End Function

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Filepaths (WinNT, W97)

    Hans, you're a star! Talk about a comprehensive answer - That's exactly what I needed!

    <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15> Mucho gracias! <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Beryl M


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •