我确定这段代码可能看起来有点熟悉但我无法使用此循环文件路径打印机代码获取文件的扩展属性。
Scripting.FileSystem object
我是否需要创建自己的shell?
代码失败:
Cells(i + ROW_FIRST - 1, 3) = objFolder.GetDetailsOf(objFile, 9)
现有代码
'objFSO: A Scripting.FileSystem object.
Private Function GetAllFiles(ByVal strPath As String, _
ByVal intRow As Integer, ByRef objFSO As Object) As Integer
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
i = intRow - ROW_FIRST + 1
Set objFolder = objFSO.getfolder(strPath)
On Error Resume Next
For Each objFile In objFolder.Files
'print Date created
Cells(i + ROW_FIRST - 1, 1) = objFile.DateCreated
'print file name
Cells(i + ROW_FIRST - 1, 2) = objFile.Name
'Author------>!!!! HERE IS THE PROBLEM !!!!
Cells(i + ROW_FIRST - 1, 3) = objFolder.GetDetailsOf(objFile, 9)
'print file path
Cells(i + ROW_FIRST - 1, 4) = objFile.Path
'Insert doc link
Cells(i + ROW_FIRST - 1, 5).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
objFile.Path, _
TextToDisplay:=objFile.Name
i = i + 1
Next objFile
GetAllFiles = i + ROW_FIRST - 1
End Function
谢谢!
答案 0 :(得分:0)
您需要使用Shell
。
在我的系统上,作者属性为20。
Sub HoldtheDoor()
Dim oShell As Object
Dim oDir As Object
Dim objFile As Object
Set oShell = CreateObject("Shell.Application")
Set oDir = oShell.Namespace("c:\temp")
For Each objFile In oDir.Items
Debug.Print oDir.GetDetailsOf(objFile, 20)
Next
End Sub