Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Importing a Directory Listing from CD to Excel

Good Morning all,

I hope you're all having a great day. I have been given
the task of creating a database of applications on CD
into Excel and I'm wondering if there is a VB function
that will output Root and sub folder names. I don't need
files contained in the folders, just folder names.
Preferably, I'd like to have 1 row for ever instance of a
folder:

Row1: Root1
Row2: Root1 Sub1
Row3: Root1 Sub1 Sub2
Row4: Root1 Sub1 Sub3 Sub3
Row5: etc...

Any ideas on how to go about doing this?

Thanks in advance and have a great one,

Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Importing a Directory Listing from CD to Excel

Mike,

This simple script should do it

Sub LoopFolders()
Dim i As Integer

Set objFSO = CreateObject("Scripting.FileSystemObject")

iRow = 0
iLevel = 0

selectFiles "c:\Windows"

Set objFSO = Nothing

End Sub

'---------------------------------------------------------------------------
Sub selectFiles(sPath)
'---------------------------------------------------------------------------
Dim Folder As Object
Dim Files As Object
Dim file As Object
Dim fldr

Set Folder = objFSO.GetFolder(sPath)

iRow = iRow + 1
iLevel = iLevel + 1

Cells(iRow, iLevel) = Folder.Path

For Each fldr In Folder.subfolders
selectFiles fldr.Path
Next
iLevel = iLevel - 1

End Sub




--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mike" wrote in message
...
Good Morning all,

I hope you're all having a great day. I have been given
the task of creating a database of applications on CD
into Excel and I'm wondering if there is a VB function
that will output Root and sub folder names. I don't need
files contained in the folders, just folder names.
Preferably, I'd like to have 1 row for ever instance of a
folder:

Row1: Root1
Row2: Root1 Sub1
Row3: Root1 Sub1 Sub2
Row4: Root1 Sub1 Sub3 Sub3
Row5: etc...

Any ideas on how to go about doing this?

Thanks in advance and have a great one,

Mike



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Importing a Directory Listing from CD to Excel

Thanks Bob, but I'm getting a runtime error on the

Set Folder = objFSO.GetFolder(sPath)

call.
Runtime error '424'
Object required

Any thoughts? I can see the path being retained in the
(sPath) variable. I don't think I should need a plugin
for this one (Office XP).

Thanks in advance,

Mike
-----Original Message-----
Mike,

This simple script should do it

Sub LoopFolders()
Dim i As Integer

Set objFSO = CreateObject

("Scripting.FileSystemObject")

iRow = 0
iLevel = 0

selectFiles "c:\Windows"

Set objFSO = Nothing

End Sub

'--------------------------------------------------------

-------------------
Sub selectFiles(sPath)
'--------------------------------------------------------

-------------------
Dim Folder As Object
Dim Files As Object
Dim file As Object
Dim fldr

Set Folder = objFSO.GetFolder(sPath)

iRow = iRow + 1
iLevel = iLevel + 1

Cells(iRow, iLevel) = Folder.Path

For Each fldr In Folder.subfolders
selectFiles fldr.Path
Next
iLevel = iLevel - 1

End Sub




--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mike" wrote in message
...
Good Morning all,

I hope you're all having a great day. I have been

given
the task of creating a database of applications on CD
into Excel and I'm wondering if there is a VB function
that will output Root and sub folder names. I don't

need
files contained in the folders, just folder names.
Preferably, I'd like to have 1 row for ever instance

of a
folder:

Row1: Root1
Row2: Root1 Sub1
Row3: Root1 Sub1 Sub2
Row4: Root1 Sub1 Sub3 Sub3
Row5: etc...

Any ideas on how to go about doing this?

Thanks in advance and have a great one,

Mike



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Directory listing Bampah Excel Discussion (Misc queries) 4 January 19th 06 03:25 PM
Listing Directory Contents in Worksheet Pablo Excel Discussion (Misc queries) 2 August 2nd 05 06:09 PM
Directory listing Nigel Chapman Excel Discussion (Misc queries) 2 April 15th 05 02:52 PM
Unix Directory/File Listing enchilada Excel Programming 0 December 10th 03 07:46 AM
Listing the contents of a directory in a spreadsheet Angelikoula Excel Programming 2 November 6th 03 01:44 PM


All times are GMT +1. The time now is 08:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"