close

Afternoon Guys.

Wondered if someone could help me.

I have a series of folders in Windows and I would like to import them,
their contents and the contents of any subfolders into an Excel file.
Does anyone know of a way I can do this either within Excel or using
third-party software?

Many thanks,

Andrew Summers --
asummers
------------------------------------------------------------------------
asummers's Profile: www.excelforum.com/member.php...oamp;userid=31807
View this thread: www.excelforum.com/showthread...hreadid=515294When you say you want to import contents, I'm assuming you want to bring
file and folder names into your worksheet. Put these two subroutines into a
module and then run the subroutine quot;DoNewFolder()quot;. It will give you a
folder browse window to select a top level folder and then present you with
a message box asking if you want to include subfolders in the listing. It
will add a new workbook where the information will be placed and you can
choose to save that workbook or not.

Sub DoNewFolder()
Application.ScreenUpdating = False
Workbooks.Add
Dim strPath As String
Dim inclSubs As Boolean

Set objShell = CreateObject(quot;Shell.Applicationquot;)
Set objFolder = objShell.BrowseForFolder(0, quot;Select Folderquot;, 0)
If objFolder Is Nothing Then
Exit Sub
Else
strPath = objFolder.Self.Path
End If

If MsgBox(quot;Include Subfolders?quot;, vbYesNo, quot;Scopequot;) = vbYes Then
inclSubs = True
Else
inclSubs = False
End If

With Range(quot;A1quot;)
.Formula = quot;Folder Contents: quot; amp; strPath
.Font.Bold = True
.Font.Size = 12
End With

Range(quot;A3quot;).Formula = quot; quot;
Range(quot;B3quot;).Formula = quot;File Namequot;
Range(quot;C3quot;).Formula = quot;Date Createdquot;
Range(quot;D3quot;).Formula = quot;Date Last Modifiedquot;
Range(quot;E3quot;).Formula = quot;Date Last Accesssedquot;
Range(quot;A3:E3quot;).Font.Bold = True

Range(quot;A2quot;).Select

ListFilesInFolder strPath, inclSubs

Application.ScreenUpdating = True

End Sub

Sub ListFilesInFolder(SourceFolderName As String, AlsoSubfolders As Boolean)
Application.ScreenUpdating = False

Dim R As Long

Set fso = CreateObject(quot;Scripting.FileSystemObjectquot;)
Set objStartFolder = fso.GetFolder(SourceFolderName)

R = Range(quot;A65536quot;).End(xlUp).Row 1

For Each itmFile In objStartFolder.Files
Cells(R, 1).Formula = quot; quot;
Cells(R, 2).Formula = itmFile.Name
Cells(R, 3).Formula = itmFile.DateCreated
Cells(R, 4).Formula = itmFile.DateLastModified
Cells(R, 5).Formula = itmFile.DateLastAccessed
R = R 1
Next itmFile

If AlsoSubfolders Then
For Each itmSub In objStartFolder.Subfolders
R = Range(quot;A65536quot;).End(xlUp).Row 1
Cells(R, 1).Formula = itmSub.Path
ListFilesInFolder itmSub.Path, True
Next itmSub
End If

Columns(quot;B:Equot;).AutoFit

Set objStartFolder = Nothing
Set fso = Nothing

End Sub
Steve Yandl
quot;asummersquot; gt; wrote in
message ...
gt;
gt; Afternoon Guys.
gt;
gt; Wondered if someone could help me.
gt;
gt; I have a series of folders in Windows and I would like to import them,
gt; their contents and the contents of any subfolders into an Excel file.
gt; Does anyone know of a way I can do this either within Excel or using
gt; third-party software?
gt;
gt; Many thanks,
gt;
gt; Andrew Summers
gt;
gt;
gt; --
gt; asummers
gt; ------------------------------------------------------------------------
gt; asummers's Profile:
gt; www.excelforum.com/member.php...oamp;userid=31807
gt; View this thread: www.excelforum.com/showthread...hreadid=515294
gt;

Sorry that doesnt meant much to me at all.

Basically when you look at windows explorer it shows the folder
stucture and you need to click on the sign to see the Sub Folders. I
need an exact copy to be exported into a Excel Speadsheet that can then
be edited.

--
asummers
------------------------------------------------------------------------
asummers's Profile: www.excelforum.com/member.php...oamp;userid=31807
View this thread: www.excelforum.com/showthread...hreadid=515294Did you select the actual top level folder you wanted to document and then
click OK on that window? It would have listed all the files in the top
folders, the the subfolders with the files inside them, then subs of subs
with their files etc. From your question, that is what I thought you
wanted.

Steve Yandlquot;asummersquot; gt; wrote in
message ...
gt;
gt; Sorry that doesnt meant much to me at all.
gt;
gt; Basically when you look at windows explorer it shows the folder
gt; stucture and you need to click on the sign to see the Sub Folders. I
gt; need an exact copy to be exported into a Excel Speadsheet that can then
gt; be edited.
gt;
gt;
gt;
gt;
gt; --
gt; asummers
gt; ------------------------------------------------------------------------
gt; asummers's Profile:
gt; www.excelforum.com/member.php...oamp;userid=31807
gt; View this thread: www.excelforum.com/showthread...hreadid=515294
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()