以下是小弟的code
Private Sub CommandButton11_click()
Dim sh As Worksheet,NewBK As Workbook
Dim Path$,Word$,ShName$,File$,Tmp$,Filter1$,Filter2$,Filter3$
Path=[b1] 'C:\tool\output\
Word=[b2] '檔名關鍵字
ShName=[b3] 'sheet name (Equi)
Filter1=[b4]
Filter2=[b5]
Filter3=[b6]
File= Dir(Path&"*.xls") '收尋檔案
if File="" then go to Ex
first =File
Do
Tmp=left(File,InStrRev(File,".")-1) '取檔案名
if InStr(File,Word) Then
Workbooks.open Path& File
On Error Resume Next
Set sh= ActiveWorkbook.Worksheets(ShName)
On Error GoTo 0
if Not sh is Nothing Then
i=i+1
'此段不會寫'
sh.Parent.Close False
End If
End If
File= Dir
Loop Until first = File Or File= ""
IF i Then
msgbox i&"筆符合檔案"
else
Newbk.close False
EX: Msgbox "無符合檔案"
End if
End Sub