|
请教
这段宏在EXCEL2003中可运行,为什么在EXCEL2007就不行?请指导。谢谢
Private Sub UserForm_Initialize()
Dim FileName$, cPath$, n%, m%
cPath = ThisWorkbook.Path
m = Len(cPath) + 1
With Application.FileSearch '从这里开始
.NewSearch
.LookIn = cPath
.FileType = msoFileTypeAllFiles
.SearchSubFolders = True
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
For i = 1 To .FoundFiles.Count
n = InStrRev(.FoundFiles(i), "\")
FileName = Mid(.FoundFiles(i), n + 1)
cPath = Mid(Left(.FoundFiles(i), n - 1), m)
If Right(FileName, 3) = "mdb" Then
导出数据库表.库名.AddItem FileName
End If
Next i
End If
End With
End Sub |
|