Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the UNC path where a file is located

Status
Not open for further replies.

Eprice

Technical User
May 6, 2003
209
US
Hi,
I have word templates that will be stored in different places depending on them being in QA or production. I need to get the UNC path and folder so I know where to automatically save the finished document. Everything I found shows how to get drive letters instead of the UNC path. Does anyone know the code to get the UNC path?
Thanks, Lisa
 
Hi Lisa, this example is much simpler:
Code:
Sub NetworkMapDrive()

Set WshNetwork = CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
DrivesStr = "Network drive Mappings:" & Chr(13)

For i = 0 To oDrives.Count - 1 Step 2
DriveStrShort = "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i + 1)
DrivesStr = DrivesStr & DriveStrShort & Chr(13)
msgbox DriveStrShort
Next
Debug.Print DrivesStr
End Sub

You may want to post your VBA queries to the VBA forum forum707 in the future.


Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
( Actually my example shows how to get the UNC of the drive letters ... I hope that helps )

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Glenn,
That works to tell me all the drive letters on our network. What I need to return is the exact path where the template is pulled from so I can write code to save the final document to a specific folder depending on where it was pulled from. Hopefully this is not impossible.
Thanks, Lisa
 
Are you saying that the template comes from a UNC that is not mapped to a disk drive letter?

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top