Hi,

how to using dir() to select .xlsx and .xlsm but NOT .xls and .xlsb files?
here is my coding:

 Dim TheFile As Variant
        Dim TheFolderPath As Variant
        TheFolderPath = "\\192.146.0.1\scm\"
        
        ChDir TheFolderPath
        TheFile = Dir(TheFolderPath & "*.xls")
        lCount = 1
        Do While TheFile <> ""
        ChDir TheFolderPath
        'to check the file exist or not
        file_exist = True
       
            Workbooks.Open filename:=TheFolderPath & TheFile

 TheFile = Dir
 
        lCount = lCount + 1
        Loop

please help, i only want the .xlsx and .xlsm file.