Hi,
Just got the new excel 2007 and foud it doesn't have the Application.FileSearch anymore, which we use quite a bit. I've been trying to work a way around it but have had no luck. I'm on a time crunch so thought for the first time I'll ask the internet for the first time out of desperation. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
></o
>
<o
></o
>
What I need to do is use VBA to look into a folder and return the file names that are in the folder, in a column on an excel sheet and each of the names be a hyperlink to the file. The code I used before is below. I would greatly appreciate any help!!!<o
></o
>
Sub Allfiles()<o
></o
>
Dim myPath As String<o
></o
>
Dim lLen As Long, i As Long<o
></o
>
Dim parts<o
></o
>
<o
> </o
>
myPath = ThisWorkbook.Path & "\Files"
With Application.FileSearch<o
></o
>
.NewSearch<o
></o
>
.LookIn = myPath<o
></o
>
.SearchSubFolders = True<o
></o
>
.Filename = "*.*"<o
></o
>
Range("j2:k6000").Select<o
></o
>
Selection.ClearContents<o
></o
>
If .Execute() > 0 Then<o
></o
>
For i = 2 To .FoundFiles.Count<o
></o
>
parts = <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com
ffice:smarttags" /><st1:City w:st="on"><st1
lace w:st="on">Split</st1
lace></st1:City>(Trim(Replace(Dir(.FoundFiles(i)), ".xls", "")))<o
></o
>
Cells(i, 8) = parts(UBound(parts))<o
></o
>
Cells(i, 9).FormulaR1C1 = "=Hyperlink(" & Chr(34) & .FoundFiles(i) _<o
></o
>
& Chr(34) & ",R[0]C[-1])"
<o
> </o
>
Else<o
></o
>
Range("a1").Select<o
></o
>
MsgBox "There were no files found."<o
></o
>
End If<o
></o
>
End With<o
></o
>
End Sub
Just got the new excel 2007 and foud it doesn't have the Application.FileSearch anymore, which we use quite a bit. I've been trying to work a way around it but have had no luck. I'm on a time crunch so thought for the first time I'll ask the internet for the first time out of desperation. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com




<o


What I need to do is use VBA to look into a folder and return the file names that are in the folder, in a column on an excel sheet and each of the names be a hyperlink to the file. The code I used before is below. I would greatly appreciate any help!!!<o


Sub Allfiles()<o


Dim myPath As String<o


Dim lLen As Long, i As Long<o


Dim parts<o


<o


myPath = ThisWorkbook.Path & "\Files"
With Application.FileSearch<o


.NewSearch<o


.LookIn = myPath<o


.SearchSubFolders = True<o


.Filename = "*.*"<o


Range("j2:k6000").Select<o


Selection.ClearContents<o


If .Execute() > 0 Then<o


For i = 2 To .FoundFiles.Count<o


parts = <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com





Cells(i, 8) = parts(UBound(parts))<o


Cells(i, 9).FormulaR1C1 = "=Hyperlink(" & Chr(34) & .FoundFiles(i) _<o


& Chr(34) & ",R[0]C[-1])"
<o


Else<o


Range("a1").Select<o


MsgBox "There were no files found."<o


End If<o


End With<o


End Sub