jongova
08-12-2013, 01:45 PM
I have a macro that includes the FileSearch function, but in the 2010 excel version it doesn't work.
I would like your help to replace this FileSearch function.
Public Function SeekExcel(xdate As Date, folderpath As String) As String
Dim tfsearch As FileSearch
Dim filename, folderpath2, months(12) As String
months(1) = "Enero"
months(2) = "Febrero"
months(3) = "marzo"
months(4) = "Abril"
months(5) = "Mayo"
months(6) = "Junio"
months(7) = "Julio"
months(8) = "Agosto"
months(9) = "Septiembre"
months(10) = "Octubre"
months(11) = "Noviembre"
months(12) = "Diciembre"
folderpath2 = folderpath & CStr(Year(xdate)) & "\" & months(Month(xdate)) & "\" & CStr(Format(Day(xdate), "00")) & "\"
' finding the file name
Set tfsearch = Application.FileSearch
With tfsearch
.LookIn = folderpath2
.FileType = msoFileTypeExcelWorkbooks
.Execute
End With
For Each xfilename In tfsearch.FoundFiles
If (InStr(xfilename, "siopsurt") = 0) And (InStr(xfilename, "siopsur") > 0) Or (InStr(xfilename, "SIOPSURT") = 0) And (InStr(xfilename, "SIOPSUR") > 0) Then
filename = xfilename
End If
Next
SeekExcel = filename
End Function
I would like your help to replace this FileSearch function.
Public Function SeekExcel(xdate As Date, folderpath As String) As String
Dim tfsearch As FileSearch
Dim filename, folderpath2, months(12) As String
months(1) = "Enero"
months(2) = "Febrero"
months(3) = "marzo"
months(4) = "Abril"
months(5) = "Mayo"
months(6) = "Junio"
months(7) = "Julio"
months(8) = "Agosto"
months(9) = "Septiembre"
months(10) = "Octubre"
months(11) = "Noviembre"
months(12) = "Diciembre"
folderpath2 = folderpath & CStr(Year(xdate)) & "\" & months(Month(xdate)) & "\" & CStr(Format(Day(xdate), "00")) & "\"
' finding the file name
Set tfsearch = Application.FileSearch
With tfsearch
.LookIn = folderpath2
.FileType = msoFileTypeExcelWorkbooks
.Execute
End With
For Each xfilename In tfsearch.FoundFiles
If (InStr(xfilename, "siopsurt") = 0) And (InStr(xfilename, "siopsur") > 0) Or (InStr(xfilename, "SIOPSURT") = 0) And (InStr(xfilename, "SIOPSUR") > 0) Then
filename = xfilename
End If
Next
SeekExcel = filename
End Function