第2个回答 2011-12-25
With Application.FileSearch
.NewSearch
.LookIn = mainpath
.SearchSubFolders = True
.Filename = "*.*"
FileType = msoFileTypeAllFiles 'msoFileTypeExcelWorkbooks
jdjd = .Execute()
If .Execute() > 0 Then
For I = 1 To .FoundFiles.Count
On Error Resume Next
If Workbooks("CDMA_CDD_TOOLS").Sheets("tools").hssite.Value = True Then
Workbooks.OpenText Filename:=.FoundFiles(I), _
DataType:=xlDelimited, Space:=True, ConsecutiveDelimiter:=True
'Workbooks.OpenText Filename:=.FoundFiles(I), DataType:=xlDelimited, Space:=True, ConsecutiveDelimiter:=True
tnameB = ParseFileName(.FoundFiles(I))
Set WSB = Workbooks(tnameB)
Call FormatHsSite.formatsheets
tnamea = Trim(Mid(Cells(1.2), 4, 30))
scopyHS WSA, WSB, tnamea, tnameB
End If
dk = 1
If Workbooks("CDMA_CDD_TOOLS").Sheets("tools").ipsite.Value = True Then
Set WSB = Workbooks.Open(Filename:=.FoundFiles(I))
tnamea = ParseFileName(.FoundFiles(I))
tnameB = "Sheet0"
scopyIP WSA, WSB, tnamea, tnameB
wsbname = ""
End If
Application.StatusBar = "正在处理:第" & I & "个文件"
Application.ScreenUpdating = False
Next I
Else
MsgBox "Folder " & sFolder & " contains no required files"
End If