+ Reply to Thread
Results 1 to 1 of 1

Macro to Get File Attributes

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    266

    Macro to Get File Attributes

    I am using the macro below to get the length (run time) of video and/or audio files in a selected directory. It works great if the files are in a sub-directory (e.g. "D:\Videos"), but for some reason, it does list the length attribute if the video/audio files are in the root directory of the specified drive (e.g. "D:"). It will list the file names, but not the length attribute. Any ideas why? Thanks.


    Sub GetDetails()
      Dim oShell As Object
      Dim oFile As Object
      Dim oFldr As Object
      Dim lRow As Long
      Dim iCol As Integer
      Dim vArray As Variant
      vArray = Array(0, 27)
      '27 = length
     
      Set oShell = CreateObject("Shell.Application")
      lRow = 1
      With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Select the Folder..."
        If .Show Then
          Set oFldr = oShell.Namespace(.SelectedItems(1))
          With oFldr
            For iCol = LBound(vArray) To UBound(vArray)
              Cells(lRow, iCol + 1) = .GetDetailsOf(.Items, vArray(iCol))
            Next iCol
            For Each oFile In .Items
                   Select Case UCase(Right(oFile, 4))  'limit extensions listed line below
                Case ".AVI", ".MP3", ".MP4", ".MPG", ".MOV", ".WMV", ".FLV", ".M4A", ".WAV", ".WMA", ".MKV", ".3gp", ".m4v", "mpeg"
              lRow = lRow + 1
              For iCol = LBound(vArray) To UBound(vArray)
                Cells(lRow, iCol + 1) = .GetDetailsOf(oFile, vArray(iCol))
              Next iCol
              End Select 'End extension limitation
            Next oFile
          End With
        End If
      End With
    End Sub
    Last edited by JBeaucaire; 10-25-2015 at 09:24 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. File Attributes
    By sparx in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2015, 03:53 PM
  2. Macro to get file attributes - length
    By Brawnystaff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2015, 12:51 PM
  3. [SOLVED] Getting NTFS file attributes
    By Kiran in forum Excel General
    Replies: 1
    Last Post: 08-04-2005, 04:05 PM
  4. [SOLVED] More File Attributes needed
    By John Keith in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-05-2005, 09:40 PM
  5. [SOLVED] [SOLVED] File Attributes
    By mworthington@ntlworld.com in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-30-2005, 03:06 AM
  6. Filecopy, file attributes
    By Eric in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2005, 10:06 AM
  7. [SOLVED] File Attributes
    By dsti3 in forum Excel General
    Replies: 1
    Last Post: 02-10-2005, 02:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1