lemonhalls
Technical User
I'm trying to extract all the files in a folder whose file name contains the word "French".
I'm using the following code, but it doesn't pick up the files eg. "treeFrench".
__________________________
Dim lastChar As String
Dim activeDir As String
activeDir = InputBox _
(Prompt:="Enter the path where the files to be merged are stored. ", _
Title:="Path", Default:="U:\SYS\") 'change default as desire
'make a new directory by the name of current month
newDir = activeDir & Format(strPreviousMonth, "mmmm") & "\"
If Dir(newDir, 16) = "" Then MkDir newDir
With Application.FileSearch
.LookIn = activeDir 'folder with files to merge
End With
'move to the end of the document to insert files
Selection.EndKey Unit:=wdStory, Extend:=wdMove
With Application.FileSearch
.NewSearch
.LookIn = activeDir
.SearchSubFolders = False
'searches for files with .doc extension
.FileName = "*.doc"
.TextOrProperty = "French"
.MatchTextExactly = True
'inserting each file one after another
For i = 1 To .FoundFiles.Count
Selection.TypeParagraph
Selection.InsertFile FileName:=.FoundFiles(i), Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdSectionBreakNextPage
Next i
I'm using the following code, but it doesn't pick up the files eg. "treeFrench".
__________________________
Dim lastChar As String
Dim activeDir As String
activeDir = InputBox _
(Prompt:="Enter the path where the files to be merged are stored. ", _
Title:="Path", Default:="U:\SYS\") 'change default as desire
'make a new directory by the name of current month
newDir = activeDir & Format(strPreviousMonth, "mmmm") & "\"
If Dir(newDir, 16) = "" Then MkDir newDir
With Application.FileSearch
.LookIn = activeDir 'folder with files to merge
End With
'move to the end of the document to insert files
Selection.EndKey Unit:=wdStory, Extend:=wdMove
With Application.FileSearch
.NewSearch
.LookIn = activeDir
.SearchSubFolders = False
'searches for files with .doc extension
.FileName = "*.doc"
.TextOrProperty = "French"
.MatchTextExactly = True
'inserting each file one after another
For i = 1 To .FoundFiles.Count
Selection.TypeParagraph
Selection.InsertFile FileName:=.FoundFiles(i), Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdSectionBreakNextPage
Next i