Give this a try
Sub ExportToTextFile()
Dim a As Variant
Dim s As String
Dim r As Range
Dim rng As Range
Dim c As Range
Dim i As Long
Dim k As Long
Dim cl As Long
ReDim a(1 To 1)
s = "C:\Dokumente und Einstellungen\Felix\Eigene Dateien\PRODUCTION\"
cl = 25
k = 1
For i = 3 To Cells(Rows.Count, 1).End(xlUp).Row
If i = 3 Then Set r = Cells(i, 1)
If Cells(i, 1).Borders(xlEdgeBottom).LineStyle <> xlLineStyleNone Then
ReDim Preserve a(1 To k)
a(k) = "c:\(" & Cells(1, cl).Value & ").printer"
Set rng = Range(r, Cells(i, 1))
k = k + 1
ReDim Preserve a(1 To k)
a(k) = s & Cells(1, cl).Value & ".prs"
For Each c In rng
If c.Offset(, 1).Value = "o" And c.Offset(-1, 1).Value <> "o" Then
k = k + 1
ReDim Preserve a(1 To k)
a(k) = CStr(s & Cells(1, cl).Value & "sw.prs")
End If
k = k + 1
ReDim Preserve a(1 To k)
a(k) = CStr(s & c.Value & ".jpg")
If c.Offset(, 1).Value = "o" And c.Offset(1, 1).Value <> "o" Then
k = k + 1
ReDim Preserve a(1 To k)
a(k) = CStr(s & Cells(1, cl).Value & ".prs")
End If
Next c
Set r = Cells(i + 1, 1)
cl = cl + 1: k = k + 1
End If
Next i
ArrayToTextFile a, "C:\Users\User\Documents\Spaces\TD1" & "\Print.txt"
MsgBox "Done...", 64
End Sub
Function ArrayToTextFile(a, strPath)
Const forWriting = 2
Dim fso, writer
Dim i As Long
Set fso = CreateObject("Scripting.FileSystemObject")
Set writer = fso.OpenTextFile(strPath, forWriting, True)
For i = LBound(a) To UBound(a)
writer.writeline a(i)
Next i
writer.Close
End Function
Bookmarks