Full folder path from BrowseForFolder
One way:
Option Explicit
Sub shellb()
Dim objShell
Dim objFolder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder _
(0, "Choose folder to be listed:", 0, 17)
If (Not objFolder Is Nothing) Then
Range("A3").Value = objFolder
Call ShowFiles(objFolder.self.Path)
End If
Set objFolder = Nothing
Set objShell = Nothing
End Sub
Sub ShowFiles(myFolderName As String)
Dim FSO As Object
Dim myFolder As Object
Dim myFile As Object
Dim iCtr As Long
Set FSO = CreateObject("Scripting.FileSystemobject")
Set myFolder = FSO.getfolder(myFolderName)
iCtr = 3
For Each myFile In myFolder.Files
iCtr = iCtr + 1
Cells(iCtr, "A").Value = myFile.Path
Cells(iCtr, "B").Value = myFile.Name
Cells(iCtr, "C").Value = myFile.datecreated
Cells(iCtr, "D").Value = myFile.Size
Next myFile
End Sub
Jon wrote:
Now I would like to use that folder path and create a list of files and
their attributes (such as date created, size, type) and paste them into
my document. How would I go about doing this?
--
Dave Peterson
|