View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_4_] Jim Thomlinson[_4_] is offline
external usenet poster
 
Posts: 1,119
Default is this an accepted way to set the path

That seems acceptable. You could also see what the UNC is for the local N
drive with this function which may or may not help...

Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA"
( _
ByVal lpszLocalName As String, _
ByVal lpszRemoteName As String, _
ByRef cbRemoteName As Long) As Long

Sub Test()
MsgBox UNCfromLocalDriveName("N")
End Sub

Function UNCfromLocalDriveName(strLocalDrive) As String
'Find UNC from Local path
'i.e. Local drive "F:" = "\\RdaServer3\sys1"
' example of usage: UNCfromLocalDriveName("P") <-Actual Drive Letter
' or UNCfromLocalDriveName(A2) <-Cell reference
'
Dim sLocal As String
Dim sRemote As String * 255
Dim lLen As Long

Application.Volatile

sRemote = String$(255, Chr$(32))

lLen = 255
sLocal = strLocalDrive & ":"

WNetGetConnection sLocal, sRemote, lLen

UNCfromLocalDriveName = Trim(sRemote)

End Function

--
HTH...

Jim Thomlinson


"Gary Keramidas" wrote:

i set a variable to the path the files are in at my location. when i take it
to the client, i have to remember to change the string to their path. so i
used the environ("username") to set it. is this a normal way to do this so
you don't always have to remember to change it?


If UCase(Environ("UserName")) = "USER" Then ' this is me at my location
fPath = "N:\My Documents\FolderName\"
Else
fPath = "\\ServerName\share\FolderName\"
End If

--


Gary