File-list generated from folder including attributes

S

Snoopy

Hey guys
My macro generates a file-name list with accordingly attributes as
"size", "Accessed date".
My problem is to expand this Explorer-information with attributes:
"Author" and "Owner".

I dont know/cantv find the code...... maybe file.author or
something????+

Here is my macro:


Sub SelectFiles(ByVal sPath)
'-----------------------------------------------------------------------
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object

Set Folder = FSO.GetFolder(sPath)

Set Files = Folder.Files
For Each file In Files
If (file.Attributes And 2 Or _
file.Attributes And 4) Then
'
Else
If InStr(1, file.Name, res, vbTextCompare) > 0 Then
cnt = cnt + 1
ReDim Preserve arFiles(3, cnt)
arFiles(0, cnt) = Folder.path
arFiles(1, cnt) = file.Name
arFiles(2, cnt) = Format(file.DateLastAccessed,
"yyyy.mm.dd hh:mm")
arFiles(3, cnt) = file.Size
End If
End If
Next file

level = level + 1
For Each fldr In Folder.Subfolders
SelectFiles fldr.path
Next
End Sub

I would realy appreciate your guidance here :)

Regards
Snoopy
 
B

Bernie Deitrick

Snoopy,

You need to use GetDetailsOf to get the extended file attributes.

Try the macro below - I assumed that sPath is a public variable, pointing to
a valid folder

HTH,
Bernie
MS Excel MVP


Sub AuthorAuthor()
Dim arrHeaders(35)
Dim objShell As Object
Dim objFolder As Object
Dim i As Integer
Dim objFile As Object
Dim strMsg As String

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(sPath)
For i = 0 To 34
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next
For Each objFile In objFolder.Items
strMsg = ""
'8 is Owner, 9 is Author
For i = 8 To 9
strMsg = strMsg & i & vbTab & arrHeaders(i) _
& ": " & objFolder.GetDetailsOf(objFile, i) & vbCrLf
Next

'This section shows all the extended file attributes, in case you want more
' For i = 0 To 34
' strMsg = strMsg & i & vbTab & arrHeaders(i) _
' & ": " & objFolder.GetDetailsOf(objFile, i) & vbCrLf
' Next

MsgBox strMsg
Next

End Sub
 
S

Snoopy

Snoopy,

You need to use GetDetailsOf to get the extended file attributes.

Try the macro below - I assumed that sPath is a public variable, pointingto
a valid folder

HTH,
Bernie
MS Excel MVP

Sub AuthorAuthor()
    Dim arrHeaders(35)
    Dim objShell As Object
    Dim objFolder As Object
    Dim i As Integer
    Dim objFile As Object
    Dim strMsg As String

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(sPath)
    For i = 0 To 34
        arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items,i)
    Next
    For Each objFile In objFolder.Items
        strMsg = ""
        '8 is Owner, 9 is Author
        For i = 8 To 9
            strMsg = strMsg & i & vbTab & arrHeaders(i) _
                     & ": " & objFolder.GetDetailsOf(objFile, i) & vbCrLf
        Next

'This section shows all the extended file attributes, in case you want more
'        For i = 0 To 34
'            strMsg = strMsg & i & vbTab & arrHeaders(i) _
'                     & ": " & objFolder.GetDetailsOf(objFile, i) & vbCrLf
'        Next

       MsgBox strMsg
    Next

End Sub














– Vis sitert tekst –

Thanks a lot Bernie
- this put me some steps forward, thoug...
this give me a subsequently message very nice!) , but how do I make a
list: Filepath / Filename / AccessedDateTime / Owner on this one? not
messages, but just a list-
 
B

Bernie Deitrick

To make a list:

Sub MakeListOfOwnersAndAuthors()
Dim objShell As Object
Dim objFolder As Object
Dim objFile As Object
Dim myRow As Long

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(sPath)

Cells(1, 1).Value = "File Name"
Cells(1, 2).Value = "Owner"
Cells(1, 3).Value = "Author"

myRow = 1

For Each objFile In objFolder.Items
myRow = myRow + 1
Cells(myRow, 1).Value = objFolder.GetDetailsOf(objFile, 0)
Cells(myRow, 2).Value = objFolder.GetDetailsOf(objFile, 8)
Cells(myRow, 3).Value = objFolder.GetDetailsOf(objFile, 9)
Next objFile

Cells.EntireColumn.AutoFit

End Sub


HTH,
Bernie
MS Excel MVP



Snoopy,

You need to use GetDetailsOf to get the extended file attributes.

Try the macro below - I assumed that sPath is a public variable, pointing
to
a valid folder

HTH,
Bernie
MS Excel MVP

Sub AuthorAuthor()
Dim arrHeaders(35)
Dim objShell As Object
Dim objFolder As Object
Dim i As Integer
Dim objFile As Object
Dim strMsg As String

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(sPath)
For i = 0 To 34
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next
For Each objFile In objFolder.Items
strMsg = ""
'8 is Owner, 9 is Author
For i = 8 To 9
strMsg = strMsg & i & vbTab & arrHeaders(i) _
& ": " & objFolder.GetDetailsOf(objFile, i) & vbCrLf
Next

'This section shows all the extended file attributes, in case you want
more
' For i = 0 To 34
' strMsg = strMsg & i & vbTab & arrHeaders(i) _
' & ": " & objFolder.GetDetailsOf(objFile, i) & vbCrLf
' Next

MsgBox strMsg
Next

End Sub














– Vis sitert tekst –

Thanks a lot Bernie
- this put me some steps forward, thoug...
this give me a subsequently message very nice!) , but how do I make a
list: Filepath / Filename / AccessedDateTime / Owner on this one? not
messages, but just a list-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top