CSV Dateien
31.07.2014 12:50:56
Tino
Hallo,
hättest ja sagen können das sich um CSV Dateien handelt,
sind ja eigentlich Textdateien mit vorgegebenen Trennzeichen.
Sub Start()
Dim sDir$, sPath$, sInhalt$
Dim arFiles()
Dim varInhalt, varTmp
Dim n&, nn&
Dim F%
Const sDelimiter$ = ";" 'TRennzeichen
sPath = "C:\Ordner\Ordner\" 'Pfad anpassen
If Right$(sPath, 1) <> "\" Then sPath = sPath & "\"
sDir = Dir$(sPath & "*.csv", vbNormal)
Do While sDir <> ""
Redim Preserve arFiles(n)
arFiles(n) = sDir
n = n + 1
sDir = Dir$()
Loop
If n > 0 Then
For n = Lbound(arFiles) To Ubound(arFiles)
F = FreeFile
Open sPath & arFiles(n) For Binary As #F
sInhalt = Space$(LOF(F))
Get #F, , sInhalt
Close
varInhalt = Split(sInhalt, vbCrLf)
Kill sPath & arFiles(n)
F = FreeFile
Open sPath & arFiles(n) For Append As #F
For nn = Lbound(varInhalt) To Ubound(varInhalt)
If nn > 0 Then
varTmp = Split(varInhalt(nn), sDelimiter)
If Ubound(varTmp) > 0 Then varTmp(1) = 25
sInhalt = Join(varTmp, sDelimiter)
Else
sInhalt = varInhalt(nn)
End If
Print #F, sInhalt
Next nn
Close #F
Next n
End If
MsgBox "Fertig!", vbInformation
End Sub
Gruß Tino