All Text Files!

All text files of a folder are collected in one text file. The appropriate parameters must be adapted. The files at the end of the article are Excelfiles of the version 2003 and 2007.

The following code belonged in "Module1"

Option Explicit
Public Sub TextFiles()
Dim intSourceNum As Integer
Dim intDestNum As Integer
Dim strFile As String
Dim strTMP As String
strFile = Dir("C:\Temp\*.txt") 'adapt
intDestNum = FreeFile()
Open "C:\All.txt" For Append As intDestNum 'adapt
Do Until strFile = ""
intSourceNum = FreeFile()
Open "C:\Temp\" & strFile For Input As intSourceNum
Do While Not EOF(intSourceNum)
Line Input #intSourceNum, strTMP
If Trim(strTMP) <> "" Then
Print #intDestNum, strTMP
End If
Close #intSourceNum
strFile = Dir
Close #intDestNum
End Sub

Sample 2003

Sample 2007


Beliebte Posts aus diesem Blog

Alle Dateien eines Ordners - Optional mit Unterordner

Formeln - auch Array - per VBA eintragen...

Excel -> Word in Textmarken (Bookmarks)...