I have used a form of the following code successfully many times to open multiple files in a folder and I understand how dir helps set the file path before the while loop, but don't quite understand how call the dir method again with no arguments right before the end of the while loop looks up the next file in the folder:
Sub OpenFiles()
Dim MyFolder As String
Dim MyFile As String
MyFolder = "C:\newFolder"
MyFile = Dir(MyFolder & "\*.xlsx")
Do While MyFile <> ""
Workbooks.Open Filename:=MyFolder & "\" & MyFile
MyFile = Dir
Loop
End Sub
When calling Dir on a string that already has been set with a value, is Dir designed to look to the next file in the list of files at that same path?