Printing all files in a folder

  • Thread starter Thread starter Jana
  • Start date Start date
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
 
Back
Top