(Solved) – Loop through files doesn’t return all files

(solved)-–-loop-through-files-doesn’t-return-all-files

I’m using this function to loop through files

Function LoopThroughFiles() As String

    Dim StrFile As String
    StrFile = Dir(ClientDir & "*", vbNormal)

    Do While Len(StrFile) > 0

        Debug.Print StrFile
        StrFile = Dir
        MsgBox (StrFile)

    Loop

End Function

In that ClientDir I have two files: blah.xml and blah.xml.debug
When I run above function MsgBox returns blah.xml.debug and then returns empty string. It doesn’t return xml file. How I can return both files and not return empty string?

Leave a Reply

Your email address will not be published. Required fields are marked *