View Full Version : How can I display a list of folders and files in window?

07-28-2012, 06:36 PM
Hi, Sorry. Wasn't sure how to ask it. I wanted to know if this was possible with VBA.

I posted a link to an example, but I only have one post, so the forum won't let me. But, the software I saw is writingoutliner. In the screenshots on the top menu, there is a picture if the software in Word. On the left there is a window of some sort that is displaying folders and the files under them.

See that screenshot where they have the file names and the folders listed? Can that be done in VBA with Excel?

I searched and saw the file scripting object, but it's the display that I'm after, not so much the simple list.


07-29-2012, 12:07 AM
Sub SelectFile()
Dim fPath As Variant
ChDir "C:\Users\Andrea\Desktop" ' change the default directory if required
fPath = Application.GetOpenFilename(Title:="Select A File") ' browse for a file
Range("A5") = fPath ' put the file name in A5
End Sub

07-29-2012, 12:55 AM
Hi, TheProgramme,

to me it looks like you´re looking for the TreeView Control. I would use this as part of an UserForm which I would place vbModeless (mode available from Excel 2000 on up) and narrow the window for Excel itself.


07-29-2012, 01:05 AM
This might go some way toward what you want: http://www.vbaexpress.com/kb/getarticle.php?kb_id=837