I am trying to convert text files into Excel workbooks, open them, and then call a macro on another module (Call DataCleanBehfMRI). Then do the same thing, looping through text files in other subfolders.

Folder structure: 

```
V:\Behavioral\Twin_behaviorTry\19510196-1\WorkingMemory.txt

V:\Behavioral\Twin_behaviorTry\19510197-1\WorkingMemory.txt

```

etc.

So each "WorkingMemory.txt" file contains data to run Macros on, for each subject (19510196-1,19510197-1, etc.).

I tried to loop through individual files, within multiple folders and tried to adapt it with text files but it just skips the code from `Workbooks.OpenText filename:=folderPath & filename, _` to `end if`. 

```
Sub LoopSubfoldersAndFiles()

Dim foo As Object
Dim folder As Object
Dim subfolders As Object
Dim MyFile As String
Dim wb As Workbook
Dim CurrFile As Object

With Application
    .ScreenUpdating = False
    .EnableEvents = False
    .Calculation = xlCalculationManual
End With

Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("V:\Behavioral\Twin_behaviorTry\")
Set subfolders = folder.subfolders
MyFile = "*.txt"

For Each subfolders In subfolders

    Set CurrFile = subfolders.Files

    For Each CurrFile In CurrFile

        If CurrFile.Name = MyFile Then

            Workbooks.OpenText filename:=folderPath & filename, _
              Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
              xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
              Comma:=False, Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), _
              Array(2, 1), Array(3, 1), Array(4, 1)), TrailingMinusNumbers:=True

            Set wb = ActiveWorkbook

            'Call a subroutine here to operate on the just-opened workbook
            Call DataCleanBehfMRI
            'close open work book

            wb.Close SaveChanges:=False

            filename = Dir
        End If
    Next

Next

Set fso = Nothing
Set folder = Nothing
Set subfolders = Nothing

With Application
    .EnableEvents = True
    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
End With

End Sub

```