I have a function that uses File System Object to get the actual network name of a drive. Today, a remote user had it crash when I tried to return the Sharename.
Code:
Function GetUNC(LocalPath As String) As String
MsgBox ("GetUNC Function")
Dim objFso As FileSystemObject
Set objFso = New FileSystemObject
Dim strDrive As String
Dim strShare As String
strDrive = objFso.GetDriveName(LocalPath)
strShare = objFso.Drives(strDrive).ShareName
GetUNC = Replace(LocalPath, strDrive, strShare)
Set objFso = Nothing
End Function
Specifically, it fails on "strShare = objfso.Drives(strDrive).ShareName" line.
The incoming LocalPath variable is "P:\GroundwaterDatabases\GWIDS\ImageLocationMap\Gl ennCounty_Book3\21N04W12A002M_LocationMap.jpg"
I want to change LocalPath to \\nasnro\Projects (i.e., replacing the LocalPath (P) with the network path (\\nasnro\projects).
Any idea why it doesn't work? It's been doing fine for months on other computers.
Thanks for any help you can provide!
Jonathan Mulder
Engineering Geologist
California Department of Water Resources