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
Loop
Close #intSourceNum
strFile = Dir
Loop
Close #intDestNum
End Sub


Sample 2003

Sample 2007

Kommentare

Beliebte Posts aus diesem Blog

Formeln - auch Array - per VBA eintragen...

Alle Dateien eines Ordners - Optional mit Unterordner

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