|
显示到‘ Cells(lRow, iCol + 1) = .getdetailsof(.Items, vArray(iCol))’
就是with块变量未设置
- Sub AAA()
- Dim iPath As String, b As Long '定义变量 iPath 为 String,i 为 长整型值
- Dim t '定义变量 t
- t = Timer 't=当前计时
- With Application.FileDialog(msoFileDialogFolderPicker) '工作于Application.FileDialog(msoFileDialogFolderPicker)
- .Title = "请选择要查找的文件夹" '.Title="请选择要查找的文件夹"
- If .Show Then '如果 .Show 则执行
- iPath = .SelectedItems(1) 'iPath=.SelectedItems(1)
- End If 'End如果
- End With 'End工作于
- If iPath = "False" Or Len(iPath) = 1 Then Exit Sub '如果 iPath="False"或者Len(iPath)=1 则执行 退出子程序
- b = 1 'i=1
- Call GetFolderFile(iPath, b) '调用 GetFolderFile(iPath,i)
-
- End Sub 'End子程序
- Public Sub GetFolderFile(ByVal nPath As String, ByRef iCount As Long) '私有的子程序 GetFolderFile(变量nPath 为 String,ByRefiCount 为 长整型值)
- Dim oShell As Object
- Dim oFile As Object
- Dim oFldr As Object
- Dim lRow As Long
- Dim iCol As Integer
- Dim vArray As Variant
- vArray = Array(0, 10, 18, 176)
- Set oShell = CreateObject("Shell.Application")
- lRow = 1
- Set oFldr = oShell.Namespace(iPath)
- With oFldr
- For iCol = LBound(vArray) To UBound(vArray)
- Cells(lRow, iCol + 1) = .getdetailsof(.Items, vArray(iCol))
- Next iCol
- For Each oFile In .Items
- lRow = lRow + 1
- For iCol = LBound(vArray) To UBound(vArray)
- On Error Resume Next
- Cells(lRow, iCol + 1) = .getdetailsof(oFile, vArray(iCol))
- Next iCol
- Next oFile
- End With
- For Each nFolder In sFolder '设定变量范围为每一个nFolder位于sFolder
- Call GetFolderFile(nFolder.Path, iCount) '调用 GetFolderFile(nFolder.Path,iCount)
- Next '下一个
-
- End Sub 'End子程序
-
复制代码
|
|