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

Keine Kommentare:

Kommentar veröffentlichen

Formeln auf einer UserForm in einer TextBox darstellen...

Formeln auf einer UserForm in einer TextBox anzeigen. Z. B. "Formula", "FormulaLocal"... und wie muss die Formel in VBA ...