mscallisto
Technical User
In the following code that I copied and modified to capture info about items on my desktop, there is a line that reads
Cells(r, 4).Formula = FileItem.DateCreated
Where can I view ALL the available object references like .DateCreated, .DateLastAccessed, .type etc?
Cells(r, 4).Formula = FileItem.DateCreated
Where can I view ALL the available object references like .DateCreated, .DateLastAccessed, .type etc?
Code:
Sub DesktopIconsAttribs()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~ Error handling
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Error GoTo MyProcedure_Error
GoTo MyProcedure_Exit
MyProcedure_Error:
If Err.Number = 70 Then
MsgBox ("Special handling for error #70 ")
Resume Next
Else
MsgBox ("Special handling for not error #70 ")
Resume Next
End If
MyProcedure_Exit:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~ Add Column Headers
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With Range("A1")
.Formula = "Icon Attributes:"
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = "File Name:"
Range("B3").Formula = "File Size:"
Range("C3").Formula = "File Type:"
Range("D3").Formula = "Date Created:"
Range("E3").Formula = "Date Last Accessed:"
Range("F3").Formula = "Date Last Modified:"
Range("G3").Formula = "Attributes:"
Range("H3").Formula = "Short File Name:"
Range("A3:H3").Font.Bold = True
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~ Setup calling parameters
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Folder Name, Include Subfolders (T/F), Show MsgBox (T/F)
' ListFilesInFolder "C:\Documents and Settings\smills\Desktop", ".xls", False, False
ListFilesInFolder "C:\Documents and Settings\smills\Desktop", ".url", False, False
ActiveWorkbook.Save
MsgBox ("Done")
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~ Main Subroutine
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub ListFilesInFolder(SourceFolderName As String, FileExtensions As String, IncludeSubfolders As Boolean, ShowMsgBox As Boolean)
Dim FSO
Dim SourceFolder, SubFolder
Dim FileItem
Dim r As Long
Set FSO = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = FSO.GetFolder(SourceFolderName)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~ two methods of determining the next avail row
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Count the used rows (first method)
r = Range("A65536").End(xlUp).Row + 1
If ShowMsgBox Then
MsgBox ("Next Avail cell " & r)
End If
i = i + 1
For Each FileItem In SourceFolder.Files
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~ look for .pst files only (for now)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xxx = Right(FileItem, 4)
'If Right(FileItem, 4) = FileExtensions Then
' display file properties
Cells(r, 1).Formula = FileItem.Path '& FileItem.Name
'MsgBox ("FileItem " & FileItem)
Cells(r, 2).Formula = FileItem.Size
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~ Make "Bold" any filesizes larger than 1.5 gig
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If FileItem.Size > 15 Then
Cells(r, 2).Font.Bold = True
End If
Cells(r, 3).Formula = FileItem.Type
Cells(r, 4).Formula = FileItem.DateCreated
Cells(r, 5).Formula = FileItem.DateLastAccessed
Cells(r, 6).Formula = FileItem.DateLastModified
Cells(r, 7).Formula = FileItem.Attributes
' Cells(r, 8).Formula = FileItem.ShortPath & FileItem.ShortName
Cells(r, 8).Formula = FileItem.Path '& FileItem.Name
r = r + 1 ' next row number
' End If
Next FileItem
If IncludeSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
ListFilesInFolder SubFolder.Path, FileExtensions, True, False
Next SubFolder
End If
Columns("C:H").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = True
End Sub