I have the following code that loops through each file in a folder and outputs the Filename thereby giving me a list of all the files in a folder.
Sub ListFiles()
'
' ListFiles Macro
'
Dim Filearray() As String, ffile As String, MyFolder As String, count As Integer
MyFolder = ActiveDocument.Path
ffile = Dir(MyFolder & "\*.doc"
count = 1
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, count:=1
Do While ffile <> ""
If ffile <> "." And ffile <> ".." Then
ReDim Preserve Filearray(count)
Filearray(count) = ffile
count = count + 1
ffile = Dir()
Selection.TypeText ffile
Selection.TypeText Chr(13)
Selection.TypeText Chr(13)
End If
Loop
Selection.TypeText count & " Files in " & MyFolder
'Documents.Add.Content.Filearray
End Sub
*******************************************
This works fine but what I would now like to do is to add some of the document properties to the list as well something like this
Name Created Date Last edited
Policy.doc 1/1/2002 12/5/2002
Users.doc 12/2/2002 23/4/2002
And so on. How do I achieve this
Many thanks for your assistance
Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
Sub ListFiles()
'
' ListFiles Macro
'
Dim Filearray() As String, ffile As String, MyFolder As String, count As Integer
MyFolder = ActiveDocument.Path
ffile = Dir(MyFolder & "\*.doc"
count = 1
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, count:=1
Do While ffile <> ""
If ffile <> "." And ffile <> ".." Then
ReDim Preserve Filearray(count)
Filearray(count) = ffile
count = count + 1
ffile = Dir()
Selection.TypeText ffile
Selection.TypeText Chr(13)
Selection.TypeText Chr(13)
End If
Loop
Selection.TypeText count & " Files in " & MyFolder
'Documents.Add.Content.Filearray
End Sub
*******************************************
This works fine but what I would now like to do is to add some of the document properties to the list as well something like this
Name Created Date Last edited
Policy.doc 1/1/2002 12/5/2002
Users.doc 12/2/2002 23/4/2002
And so on. How do I achieve this
Many thanks for your assistance
Neil Berryman
IT Trainer
neil_berryman@btopenworld.com