Christopher_Green
New Member
- Joined
- Apr 28, 2013
- Messages
- 12
Hi,
I have the below macro that will look in a specific File location / directory and produce me a list of files within that area.
If possible i would like to change the macro so that rather then me going into the VBA to change the location an input message box asks me which file location i want to generate the list from.
I would also then like the Macro to concatenate this information togeather for me to produce the full file path e.g. (C:\Documents and Settings\greenc4\My Documents\Document 1.doc)
The last things is i would like it to produce this information on the same sheet and not add a new one when the macro runs.
I hope this makes sense.
Here is the macro:
I am thankful for any help you can give.
Thanks
Christopher Green
I have the below macro that will look in a specific File location / directory and produce me a list of files within that area.
If possible i would like to change the macro so that rather then me going into the VBA to change the location an input message box asks me which file location i want to generate the list from.
I would also then like the Macro to concatenate this information togeather for me to produce the full file path e.g. (C:\Documents and Settings\greenc4\My Documents\Document 1.doc)
The last things is i would like it to produce this information on the same sheet and not add a new one when the macro runs.
I hope this makes sense.
Here is the macro:
Code:
Sub List_All_Files()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim ws As Worksheet
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ws = Worksheets.Add
'Get the folder object associated with the directory
Set objFolder = objFSO.GetFolder("C:\")
ws.Cells(1, 1).Value = "The files found in " & objFolder.Name & "are:"
'Loop through the Files collection
For Each objFile In objFolder.Files
ws.Cells(ws.UsedRange.Rows.Count + 1, 1).Value = objFile.Name
Next
'Clean up!
Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing
End Sub
I am thankful for any help you can give.
Thanks
Christopher Green