J
Josh
I used the Macro from the Word MVP site to insert the names of files
in a folder into my Word document. What I want to do now is limit the
files that are inserted by a date range. I can create a userform that
I can put a start date and finish date in but I don’t know how to
bring in the creation date of the files. This is what I’ve done so
far:
Sub InsertNamesOfFilesInAFolder()
Dim MyPath As String
Dim MyName As String
MyPath = "H:\Word"
MyName = "S:\Requisitions"
'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() <> -1 Then Exit Sub
MyPath = .Directory
End With
'strip quotation marks from path
If Len(MyPath) = 0 Then Exit Sub
If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If
'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName <> ""
Selection.InsertAfter MyName & vbCr
MyName = Dir
Loop
'collapse the selection
Selection.Collapse wdCollapseEnd
End Sub
Any help would be awesome! Thank you in advance!
-Josh
in a folder into my Word document. What I want to do now is limit the
files that are inserted by a date range. I can create a userform that
I can put a start date and finish date in but I don’t know how to
bring in the creation date of the files. This is what I’ve done so
far:
Sub InsertNamesOfFilesInAFolder()
Dim MyPath As String
Dim MyName As String
MyPath = "H:\Word"
MyName = "S:\Requisitions"
'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() <> -1 Then Exit Sub
MyPath = .Directory
End With
'strip quotation marks from path
If Len(MyPath) = 0 Then Exit Sub
If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If
'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName <> ""
Selection.InsertAfter MyName & vbCr
MyName = Dir
Loop
'collapse the selection
Selection.Collapse wdCollapseEnd
End Sub
Any help would be awesome! Thank you in advance!
-Josh