VBS 遍历文件夹下所有Excel文件

Function FilesTree(sPath) 
  Dim i : i=0
  on error resume Next
  Set oFso = CreateObject("Scripting.FileSystemObject")  
  Set oFolder = oFso.GetFolder(sPath)       
  Set oFiles = oFolder.Files  
  For Each oFile In oFiles
    If Right(oFile.Path,3)="xls" Then
       Msgbox oFile.Path 
       i=i+1
    End If
  Next 
  Msgbox "您的"&sPath&"目录下,一共存在"&i&"个Excle文件"
  Wscript.Quit
End Function 

 

posted @ 2011-06-16 00:31  Sirrah  阅读(7280)  评论(0编辑  收藏  举报