• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to open each file from a folder

ThrottleWorks

Excel Ninja
Hi,

I have a folder.

This folder will have excel file with different extensions.
XLS, XLSM or XLSB. Files can be of any excel extension.

How do I open each file from the folder.
Can anyone please help me in this.
 
Use dir function.
Ex:
Code:
Sub Demo()
Dim fPath As String: fPath = "C:\Test\" 'Note you should have "\" at end of path string
Dim mFile As String

mFile = Dir(fPath & "*.xls*")
Do While Len(mFile) > 0
    Workbooks.Open (fPath & mFile)
    mFile = Dir()
Loop
End Sub
 
Last edited:
Hi @Chihiro sir, thanks a lot for the help.
I tried somewhat similar code. I copied code from Google.
But somehow code is opening only XLSM file and skipping 97-2003 workbook.

Please give me sometime to check and revert.
Have a nice day ahead. :)
 
Back
Top