The following code gives the error "subscript out of range":
Sub Workbooks2(str)
Workbooks.Open (ThisWorkbook.path & "\" & str)
Workbooks(ThisWorkbook.path & "\" & str).Close ' <<<<< subscript out of range error
End Sub
The following works (removed the path to the file in the Close command):
Sub Workbooks2(str)
Workbooks.Open (ThisWorkbook.path & "\" & str)
Workbooks(str).Close
End Sub