VBA 遍历指定目录下所有Excel文件并读取文件名
Sub GetSheetName()
    Dim Path As String
    Dim File As String
    Dim WB As Workbook
    Dim sht As Worksheet
    
        Application.ScreenUpdating = False
        Path = ThisWorkbook.Path & "/"
        File = Dir(Path & "*.xlsx")
        Do While File <> ""
            Set WB = Workbooks.Open(Path & File)
            For Each sht In WB.Sheets
                MsgBox sht.Name
            Next
            File = Dir
        Loop
        Application.ScreenUpdating = True
End Sub
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号