RE:recuperar la ruta de un archivo
Puedes utilizar esto: Espero q te sirva
'en el path le metes el directorio en el q kieras buscar: C:\, D:\... y en ResPath te devolvera la ruta q buscas.
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Function Buscar_Prog(path As String, ResPath As String)
Dim SearchStr As String
Dim FileName As String ' Variable del nombre de fichero
Dim DirName As String ' Nombre del subdirectorio
Dim dirNames() As String ' Buffer para la entrada de nombres de directorios
Dim nDir As Integer ' Numero de directorios en este path
Dim i As Integer ' Contador para el for
Dim hSearch As Long ' Handle para buscar
Dim WFD As WIN32_FIND_DATA
Dim Cont As Integer
'AQUI METES EL FICHERO QUE BUSCAS
SearchStr = "FICHERO"
If Right(path, 1) <> "\" Then path = path & "\"
' Buscar en los subdirectorios
nDir = 0
ReDim dirNames(nDir)
Cont = True
hSearch = FindFirstFile(path & "*", WFD)
If hSearch <> INVALID_HANDLE_VALUE Then
Do While Cont
DirName = StripNulls(WFD.cFileName)
' Ignorar estos dos directorios
If (DirName <> ".") And (DirName <> "..") Then
' Comprobar el directorio mediante la comparación de bits
If GetFileAttributes(path & DirName) And FILE_ATTRIBUTE_DIRECTORY Then
dirNames(nDir) = DirName
nDir = nDir + 1
ReDim Preserve dirNames(nDir)
End If
End If
Cont = FindNextFile(hSearch, WFD) 'Buscar el siguiente subdirectorio
Loop
Cont = FindClose(hSearch)
End If
' Sumar los tamaños de los ficheros dentro de este directorio
hSearch = FindFirstFile(path & SearchStr, WFD)
Cont = True
If hSearch <> INVALID_HANDLE_VALUE Then
While Cont
FileName = StripNulls(WFD.cFileName)
If (FileName <> ".") And (FileName <> "..") Then
Buscar_Prog = Buscar_Prog + (WFD.nFileSizeHigh * MAXDWORD) + WFD.nFileSizeLow
ResPath = path & FileName
End If
Cont = FindNextFile(hSearch, WFD) ' Get next file
Wend
Cont = FindClose(hSearch)
End If
' Si hay subdirectorios...
If nDir > 0 Then
' Comprobarlos recursivamente
For i = 0 To nDir - 1
Buscar_Prog = Buscar_Prog + Buscar_Prog(path & dirNames(i) & "\", ResPath)
Next i
End If
End Function