Hello,

I am running this script:

 strFile = Dir(MyPath & "\*")
    Do While Len(strFile) > 0
        Debug.Print strFile     
        
        '--------------Check for MATCH in folder-----------------------------------------------
        
        If Len(Dir(FoldercPath & strFile)) = 0 Then
            MsgBox " False"
        Else
            MsgBox " Match"
        End If
                
        '---------------END Check for MATCH in folder----------------------------------------------
      
        strFile = Dir        
 Loop
After the first round in the loop, I am getting a Run Time Error '5' - Invalid procedure., however, if I remove the "IF" procedure, the script runs through.


What is wrong here? Could you please advise?
Thanks