Printing all files in a folder

J

Jana

How/where would I type this macro to print all the files
in a given folder? The pathname is
C:\WINDOWS\Desktop\Training

Thank you!

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

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

While sDocName <> ""
' Print the file.
Application.PrintOut FileName: = sDocName
' 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