Printing List of Folder Contents

J

Jana

Thank you for your suggestions. I still cannot find a way
to print a list of the folder contents.

I tried entering CMD (Start menu, select Rund, enter CMD)
and got the following message: "Cannot find the file 'CMD'
(or one of its components). Make sure the path and
filename are correct and that all required libraries are
available."

I tried entering C:\WINDOWS\Desktop\Training>listing.txt
All that did was open the folder; no txt file.

The macro that was suggested (see below) looks great, but
where do I enter all that information? I'm not familiar
with programming, but think I could figure out where to
insert my specific information (pathname+file).

MACRO
Sub ListDocNamesInFolder()
Dim sMyDir As String
Dim sDocName As String

' The path to obtain files.
sMyDir = "C:\My Documents\"
sDocName = Dir(sMyDir & "*.DOC")

' Add new document.
Documents.Add

' Insert folder name and file names in document.
Selection.TypeText "Documents in folder " & sMyDir &
vbCr & vbCr
While sDocName <> ""
' Insert filename in document.
Selection.TypeText sDocName & vbCr
' Get next file name.
sDocName = Dir()
Wend
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top