combining documents

  • Thread starter Thread starter Tatyana.Galkina
  • Start date Start date
T

Tatyana.Galkina

Hello,
How do I combine many *.txt docoments into one Word document, not
inserting them one-by-one?
Thanks in advance.

Tatyana.
 
I can help you. This applies for Word XP. Let's hope the same thing is for
the other versions.
So, when you run Word, the task pane opens on the right. If it does not,
just choose View - Task Pane.
In the task pane choose General Templates under New from template. Click the
Other Documents tab and then Batch Conversion Wizard.
When the Wizard runs, follow the instructions on the screen.
You are then ready!
 
Thanks a lot, Marin, but with this Batch Conversion Wizard the only thing
I could accomplish is converting all my *.txt files into the same number
of *.doc files. It worked fine, but I would rather have them all in one
Word document. Is there any way to do it, other than inserting each one of
them into a Word document?
 
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
 
Back
Top