• Path syntax (2003 sp2)

    Author
    Topic
    #440921

    When refering to a file in one of my procedures I use something like “M:TOP Technical ServicesDatabaseSomeFile”. Of course “M” is a network drive. The problem is the same drive used by another department is designated “R” so when the user in that department runs the procedure they get an error. The Novell prefix to the drive is “Tos on ‘Ppnwws07Vol1GroupPa'” regardless of the letter assigned. Is there a way to use that in the path syntax? I have tried some variations and get the same error, Path not Found.

    Any suggestions?

    Viewing 1 reply thread
    Author
    Replies
    • #1057315

      Does this work?

      “‘Ppnwws07Vol1GroupPaTosTOP Technical ServicesDatabaseSomeFile”

      Note the double backslash at the beginning.

      • #1057317

        No it does not. Did you intend the single quote after the double quote at the beginning of the path? I did try as you had written and with the single quote removed.

        • #1057318

          No, the single quote was a mistake in copying/pasting.

          I’d ask your network admin – he or she can undoubtedly tell you what the UNC path of your M: drive is.

          Or run this little procedure:

          Sub ShowUNC()
          Dim objDrives As Variant
          Dim strDriveName As String
          Dim i As Integer

          strDriveName = “M:”
          Set objDrives = CreateObject(“WScript.Network”).EnumNetworkDrives
          For i = 0 To objDrives.Count – 1 Step 2
          If objDrives(i) = strDriveName Then
          Debug.Print objDrives(i + 1)
          Exit For
          End If
          Next i
          End Sub

          It should show the UNC path for the M: drive in the Immediate window.

          • #1057324

            Your procedure yeilded PPNWWS07VOL1GROUPPATOS. I plugged it in and it worked. Many thanks.

            The education I am getting here is priceless.

    • #1057325

      Great! (Apart from the misplaced single quote, that appears to be identical to what I proposed in my first reply)

      • #1057326

        Big Oops on me. I missed the TOS on your first reply. Very sorry. But I really like that procedure.

        • #1057327

          The procedure was tailored for this situation. If you’d like to use it more often, you can change it to a function with an argument:

          Function ShowUNC(strDriveName As String) As String
          Dim objDrives As Variant
          Dim i As Integer

          Set objDrives = CreateObject("WScript.Network").EnumNetworkDrives
          For i = 0 To objDrives.Count - 1 Step 2
          If objDrives(i) = strDriveName Then
          ShowUNC = objDrives(i + 1)
          Exit For
          End If
          Next i
          End Function

          You can type

          ? ShowUNC("P:")

          in the Immediate window to see the UNC path of the P: drive, and you can use it in your code:

          Dim strDrivePath As String
          Dim strUNC As String
          strDrivePath = "L:CommonTest.mdb"
          strUNC = ShowUNC(Left(strDrivePath, 2))

    Viewing 1 reply thread
    Reply To: Path syntax (2003 sp2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: