|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
deletezhl 发表于 2012-3-29 12:05
在office2010中试验是不成功的
'修改为07版,代码如下,
Sub wjlj() '适用于07版
Dim fso As Object
Dim objFile, objFolder
Dim i As Integer
Range("A2:F65536").ClearContents
Set fso = CreateObject("Scripting.FileSystemObject")
Application.DisplayAlerts = False
Directory = [G1].Value
' On Error Resume Next
Folder = Directory
Application.ScreenUpdating = False
Set objFolder = fso.getFolder(Folder)
i = 1
For Each objFile In objFolder.Files '文件名Files,文件夹SubFolders
i = i + 1
Cells(i, 1) = Folder
Cells(i, 2) = objFile.Name
Cells(i, 3) = objFile.Type
Cells(i, 4) = objFile.Size
Cells(i, 5) = objFile.DateLastModified
ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 2), Address:=Folder & objFile.Name
Next
End Sub
可能是少了 Directory = [G1].Value
|
|