Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

view object references ?? 2

Status
Not open for further replies.

mscallisto

Technical User
Jun 14, 2001
2,990
US
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?



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
 



Hi,

"Where can I view ALL the available object references ..."

Object Properties & Methods can be viewed in...
[tt]
VB Help

Object Browser

Watch window

VB Editor - enter object, DOT and observe a popup list of available Properties & Methods.
[/tt]



Skip,

[glasses] [red][/red]
[tongue]
 
You use late binding to Microsoft Scripting Runtime library. After referencing 'scrrun.dll' Skip's hint will start working (for File object).
You can consider to use 'shell32' library ('shell32.dll') to explore links.

combo
 
Thanks Skip and combo....I'm getting close !

While in macro editor I clicked View Object Browser (F2),
selected [All Libraries] and see tons of (Classes), each when selected show all their {members} and their properties below.

What class should I be looking for?

I searched for {member} "File Name" to isolate all with {Classes) where it appears but none are what I want.

If it's because I need to follow combo's instructions, I'm afraid I don't know how. I need a bit more help.

thanks for your patience
sam
 
First check in <Libraries> list in object browser if you can find 'Scripting'. If not, in Tools>References find 'Microsoft Scripting Runtime' and tick it. If you can't find it, go 'Browse..' and choose 'scrrun.dll' library. Should be in system directory.
Now the 'Scripting' library should be available in browser, select it and find 'File' class. Members are its properties, methods and events.

After:
Set FSO = CreateObject("Scripting.FileSystemObject")
you create new FileSystemObject, but vba does not know about it earlier. Having a reference to scripting library you can declare and instantiate FSO precisely:
Dim FSO as FileSystemObject
Set FSO = New FileSystemObject
The same can be done with File object.
The advantage of above early binding is speed, intellisense hints when coding and possibility to browse objects in object browser.

combo
 
Thanks very much everyone, finally I can see where they hid all the good stuff and how to get there. (at least I think I can !!)



Stop by the Adobe Photoshop Forum sometime and I'll buy the first round.

sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top