Hi Tatyana,
I use the macro below to combine all docs in some folder into one document.
It works with all kinds of files that Word recognizes automatically...
With text files, you might get a choice about the encoding. If the default
is ok, you might try to change "ConfirmConversions:=True" to
"ConfirmConversions:=False".
The order in which the files are inserted can be changed
(ascending/descending, by file name, type, date, size).
I usually copy/paste the path of the folder directly from the Explorer into
the macro, and start the macro with F5.
Regards,
Klaus
Sub DocKumul()
'
Dim i
Dim Path1 As String
Path1 = "C:\Dokumente und Einstellungen\Administrator\Eigene Dateien\RWB
2004\Am\Nach_Word" ' Set Path.
With Application.FileSearch
.NewSearch
.LookIn = Path1
.SearchSubFolders = True
.FileName = "*"
.FileType = msoFileTypeAllFiles
.Execute SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending
'
' SortBy:
' msoSortByFileName
' msoSortByFileType
' msoSortByLastModified
' msoSortBySize
'
' SortOrder:
' msoSortOrderAscending
' msoSortOrderDescending
'
MsgBox "There were " & _
.FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
' If you want to insert the file name:
' Selection.TypeText .FoundFiles(i)
' Selection.TypeParagraph
Selection.InsertFile FileName:=.FoundFiles(i), _
ConfirmConversions:=True
' If you want to insert a section break:
' Selection.InsertBreak _
Type:=wdSectionBreakNextPage
Next i
End With
End Sub
Regards,
Klaus