Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Aquiring Directory names
Good afternoon all, Would like to know how to... 1. Aquire a list of folder names 2. Add the list to worksheets("").range("") 3. Add the list from the range in the worksheet to a combobox EG: Press a button it looks in EXAMPLE location: "X:/EXAMPLE/EXAMPLE/" Then returns the list of directories within this location. The list i then added to a worksheet, and then to a combobox. Thank you in advance -- aking198 ----------------------------------------------------------------------- aking1987's Profile: http://www.excelforum.com/member.php...fo&userid=1539 View this thread: http://www.excelforum.com/showthread.php?threadid=31375 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Aquiring Directory names
Here is some code to get a list of all folders into a range. To add it to a
combobox, link the cb to the range. Dim FSO As Object Dim cnt As Long Dim arfiles Sub Folders() Dim i As Long Dim sFolder As String Set FSO = CreateObject("Scripting.FileSystemObject") arfiles = Array() cnt = 0 sFolder = "C:\myTest" ReDim arfiles(1) If sFolder < "" Then SelectFiles sFolder Worksheets.Add.Name = "Folders" With ActiveSheet For i = LBound(arfiles) To UBound(arfiles) .Cells(i + 1, 1) = arfiles(i) Next .Columns("A:Z").EntireColumn.AutoFit End With End If End Sub '----------------------------------------------------------------------- Sub SelectFiles(Optional sPath As String) '----------------------------------------------------------------------- Dim fldr As Object Dim Folder As Object Dim file As Object Dim Files As Object ReDim Preserve arfiles(cnt) arfiles(cnt) = sPath cnt = cnt + 1 Set Folder = FSO.GetFolder(sPath) For Each fldr In Folder.Subfolders SelectFiles fldr.Path Next End Sub -- HTH RP (remove nothere from the email address if mailing direct) "aking1987" wrote in message ... Good afternoon all, Would like to know how to... 1. Aquire a list of folder names 2. Add the list to worksheets("").range("") 3. Add the list from the range in the worksheet to a combobox EG: Press a button it looks in EXAMPLE location: "X:/EXAMPLE/EXAMPLE/" Then returns the list of directories within this location. The list is then added to a worksheet, and then to a combobox. Thank you in advance. -- aking1987 ------------------------------------------------------------------------ aking1987's Profile: http://www.excelforum.com/member.php...o&userid=15393 View this thread: http://www.excelforum.com/showthread...hreadid=313753 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
converting email address names in a range of cells to real names | Excel Worksheet Functions | |||
Aquiring data from one sheet to another sheet in the same workbook | Excel Worksheet Functions | |||
to convert all the file names in one directory to .xls? | Excel Discussion (Misc queries) | |||
Change names of files in a folder to match names in Excel Column | Excel Programming | |||
Check if directory empty OR no of files in directory. | Excel Programming |