Gruppe
Extern
Problem
Wie kann ich eine Textdatei mit vorgegebenen Feldlängen anlegen?
StandardModule: basMain
Sub Aufruf()
Dim sPath As String
sPath = Application.DefaultFilePath & "\Test.txt"
Call FesteFeldBreite(Array(12, 14, 16), sPath)
End Sub
Private Sub FesteFeldBreite( _
vArr As Variant, sFile As String)
Dim iRow As Integer, iCol As Integer, iCount As Integer
Dim sTxt As String, sAct As String
Close
Open sFile For Output As #1
With Range("A1").CurrentRegion
For iRow = 1 To .Rows.Count
For iCol = 1 To .Columns.Count
iCount = vArr(iCol - 1)
sAct = Cells(iRow, iCol).Value
sAct = sAct & String(iCount - Len(sAct), " ")
sTxt = sTxt & sAct
Next iCol
Print #1, sTxt
sTxt = ""
Next iRow
End With
Close
MsgBox "Die Textdatei wurde angelegt:" & vbLf & sFile
End Sub