PDA

View Full Version : Solved: got upgraded and Files functions dont work



figment
04-21-2008, 03:40 PM
i just got upgraded to office 2007 and this function stopped working

Function list1(location As String, start As Long)
Dim a As Long
With Application.FileSearch
Application.FindFile
.LookIn = location
.FileType = msoFileTypeAllFiles
.SearchSubFolders = True
If (.Execute <> 0) Then
For a = 1 To .FoundFiles.Count
If LCase(Right(.FoundFiles.Item(a), 3)) = "dwg" Then
Worksheets("Files").Range("A" & start) = .FoundFiles.Item(a)
start = start + 1
End If
Next
End If
End With
list1 = start
End Function

i use this function may many times a day, if some one could help me replace i would be vary greatfull

jolivanes
04-21-2008, 04:29 PM
From Richard Schollar:


Code: Sub testit()
myvar = FileList("C:\Test3")
If TypeName(myvar) <> "Boolean" Then
For i = LBound(myvar) To UBound(myvar)
Debug.Print myvar(i)
Next
Else
MsgBox "No files found"
End If
End Sub



Function FileList(fldr As String, Optional fltr As String = "*.*") As Variant
Dim sTemp As String, sHldr As String
If Right$(fldr, 1) <> "\" Then fldr = fldr & "\"
sTemp = Dir(fldr & fltr)
If sTemp = "" Then
FileList = False
Exit Function
End If
Do sHldr = Dir
If sHldr = "" Then Exit Do
sTemp = sTemp & "|" & sHldr
Loop
FileList = Split(sTemp, "|")
End Function


Richard

John

jolivanes
04-21-2008, 08:29 PM
Here is some more info to be had.

http://www.mrexcel.com/board2/viewtopic.php?t=272033&sid=52324b58cfb58b5512176c503952f4f9

http://www.ozgrid.com/forum/showthread.php?t=61780

http://www.excelforum.com/showthread.php?t=549046

John

figment
04-22-2008, 06:43 AM
thanks jolivanes