其他分享
首页 > 其他分享> > VBA 遍历指定目录下所有Excel文件并读取文件名

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

  

标签:Dim,VBA,遍历,sht,WB,Excel,Application,File,Path
来源: https://www.cnblogs.com/luoye00/p/16418241.html