?
Solved

Create list in excel of all folders within a directory

Posted on 2011-02-17
5
Medium Priority
?
424 Views
Last Modified: 2012-05-11
I am a bit confused on how to come up with a macro that lists the folders in a directory

Directory: Q:\Deburr issue\WT Review\Ship 0008

There are also some .zip files in this directory, but i just want to list the folders.

Thanks,

Brandon
0
Comment
Question by:KnutsonBM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34915445
Try this:
Sub PlainFolderListing()
   Dim fso As FileSystemObject, fdrSelected, fdrSub, filTemp
   Dim strFilePath As String, rngOutput As Range
   
   ' change folder as required
   strFilePath = "Q:\Deburr issue\WT Review\Ship 0008"
   
   ' change list destination as required
   Set rngOutput = ActiveSheet.Range("A1")
   
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set fdrSelected = fso.GetFolder(strFilePath)
   For Each fdrSub In fdrSelected.SubFolders
      rngOutput.value = fdrSub.Path
      Set rngOutput = rngOutput.Offset(1)
   Next fdrSub
   Set fso = Nothing

End Sub

Open in new window

0
 
LVL 6

Author Comment

by:KnutsonBM
ID: 34915462
at Dim fso As FileSystemObject i get 'Compile Error: User-defined type not defined'


any thoughts

Brandon
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 34915465
Change that to:
Dim fso As Object

Open in new window

0
 
LVL 6

Author Comment

by:KnutsonBM
ID: 34915482
what do i need to do to remove the path and leave just the name of the folder on the output?
0
 
LVL 6

Author Comment

by:KnutsonBM
ID: 34915491
nevermind i got it, changed fdrSub.Path to fdrSub.Name
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question