With Application.FileSearch '查找
.LookIn = "D:\工作\now\2005\CIGAML " '范围为此目录下"
.Filename = "*.xls"
.Execute msoSortByFileName '执行查找过程,并且将查询结果按文件名排序
For Each s In .FoundFiles
Application.EnableEvents = False
If s <> twb.FullName And s <> "D:\工作\now\2005\CIGAML " & "\BOOK*.xls" Then '指定目录下不打印的文件
Set wb = Workbooks.Open(s, , True)
wb.Sheets("Income Rec'd-note 6").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWindow.Close
End If
Next
End With
Set twb = ThisWorkbook
Dim s
With Application.FileSearch '查找
.LookIn = "D:\工作\now\test " '范围为此目录下"
.Filename = "*.xls"
.Execute msoSortByFileName '执行查找过程,并且将查询结果按文件名排序
For Each s In .FoundFiles
Application.EnableEvents = False
If s <> twb.FullName And s <> "D:\工作\now\test\kill.xls" Then
Set wb = Workbooks.Open(s, , True)
wb.Sheets("Income Rec'd-note 6").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWindow.Close SaveChanges:=False
End If