Export folder/file listings from Windows Explorer to Excel/Word.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to be able to take a file/folder listing from Windows Explorer
and copy it into Excel or Word.

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...4d2a587&dg=microsoft.public.excel.programming
 
In the event that Microsoft does not get around to your request, here's a
small macro that will do that for you. Just change the path in the DIR
command to the directory you want the files listed from:

Sub PostFileNames()

Dim strDir As String
Dim strFile As String
Dim lngRow As Long

ActiveWorkbook.Worksheets("Sheet1").Activate
Range("A1").Select
strDir = "C:\*.*"
strFile = Dir(strDir)

Do While strFile <> ""
ActiveCell.Offset(lngRow).Value = strFile
lngRow = lngRow + 1
strFile = Dir
Loop

End Sub
 
Hi CandiceMyers

If you use local folders this is a way for the folder C:\Data to copy to a txt file

Shell "CMD /C DIR C:\data\ /B /S > C:\MYFILES.TXT"
Shell "notepad.exe C:\MYFILES.txt", vbNormalFocus

Check out also this way
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q272623&

You can change it to this to display the txt file and not print

@echo off
dir %1 /-p /b /o:gn /s > "%temp%\Listing.txt"
start notepad "%temp%\Listing.txt"
exit
 
Back
Top