E
Ed
I found a macro which writes the names of all files in a folder to a
document. I would like to have this macro search subfolders, too, and write
those doc names to the document. Can someone point me in the right
direction, please?
Ed
Sub ListDocNames()
Dim sMyDir As String
Dim sDocName As String
' The path to obtain files.
sMyDir = "C:\Documents and Settings\Folder1\Folder2"
sDocName = Dir(sMyDir & "\*.doc")
' Add new document.
Documents.Add
' Insert file names in document.
While sDocName <> ""
' Insert filename in document.
Selection.TypeText sMyDir & "\" & sDocName & vbCr
' Get next file name.
sDocName = Dir()
Wend
' Save file
ActiveDocument.SaveAs FileName:=sMyDir & "\File Paths.doc"
ActiveDocument.Close
End Sub
document. I would like to have this macro search subfolders, too, and write
those doc names to the document. Can someone point me in the right
direction, please?
Ed
Sub ListDocNames()
Dim sMyDir As String
Dim sDocName As String
' The path to obtain files.
sMyDir = "C:\Documents and Settings\Folder1\Folder2"
sDocName = Dir(sMyDir & "\*.doc")
' Add new document.
Documents.Add
' Insert file names in document.
While sDocName <> ""
' Insert filename in document.
Selection.TypeText sMyDir & "\" & sDocName & vbCr
' Get next file name.
sDocName = Dir()
Wend
' Save file
ActiveDocument.SaveAs FileName:=sMyDir & "\File Paths.doc"
ActiveDocument.Close
End Sub