Article ID: 201993
Article Last Modified on 10/11/2006
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
For more information about Dir function, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Dir function in the Office Assistant or the Answer Wizard, and then click Search to view the topic.212536 OFF2000: How to Run Sample Code from Knowledge Base Articles
ARTICLE-ID: 226118
TITLE : OFF2000: Programming Resources for Visual Basic for Applications
Additional query words: vb vbe
Keywords: kbdtacode kbhowto kbmacroexample kbprogramming KB201993