Consulting

Results 1 to 4 of 4

Thread: Solved: got upgraded and Files functions dont work

  1. #1
    VBAX Tutor
    Joined
    Aug 2007
    Posts
    273
    Location

    Solved: got upgraded and Files functions dont work

    i just got upgraded to office 2007 and this function stopped working

    [vba]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[/vba]

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

  2. #2
    From Richard Schollar:

    [vba]
    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
    [/vba]

    [vba]
    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
    [/vba]

    Richard

    John

  3. #3

  4. #4
    VBAX Tutor
    Joined
    Aug 2007
    Posts
    273
    Location
    thanks jolivanes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •