Results 1 to 3 of 3

Import Folder names (1st level only) into excel

Threaded View

  1. #1
    Registered User
    Join Date
    01-11-2011
    Location
    London, england
    MS-Off Ver
    Excel 2003
    Posts
    23

    Import Folder names (1st level only) into excel

    Hey guys,

    So i'm trying to import a list of folder names but only 1st level and not any subfolders - make sense?
    So I got some wicked code from the net that imports folder names and subfolders however I only want to import the lst level of folder names:

    Sub ListThem()
       Dim startRange As Range
     
      Sheet1.Cells.Clear
      Set startRange = Sheet1.Range("A1")
      'Parent Directory - Change this to whichever directory you want to use
      ListFoldersAndInfo "C:\Documents and Settings\Administrator\My Documents", startRange
    End Sub
     
     
    Sub ListFoldersAndInfo(foldername As String, Destination As Range)
      Dim FSO As Object
      Dim Folder As Object
      Dim R As Long
      Dim SubFolder As Object
      Dim Wks As Worksheet
     
        Set FSO = CreateObject("Scripting.FileSystemObject")
     
          Set Folder = FSO.GetFolder(foldername)
          Destination = Folder.Name
          Destination.Offset(0, 1) = Folder.Path
          Destination.Offset(0, 2) = Folder.Size
          Set Destination = Destination.Offset(1, 0)
     
          For Each SubFolder In Folder.SubFolders
             ListFoldersAndInfo Folder.Path & "\" & SubFolder.Name, Destination
          Next SubFolder
     
        Set FSO = Nothing
     
    End Su
    P.S if the code was taken from:
    http://www.excelforum.com/excel-prog...-in-excel.html

    Thanks

    Wido
    Last edited by widodude; 06-20-2011 at 09:53 AM.

Thread Information

Users Browsing this Thread

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

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