Buenas Tardes tengo el siguiente código para crear un archivo de texto que esta delimitado por espacios, intente grabarlo como PRN pero el máximo es de 240 caracteres, he agregado unas columnas mas a mi archivo pero por algún motivo las columnas adicionales las graba en la parte de abajo
'Genera Archivo txt
f = 1
For I = 6 To 84
If IsEmpty(Sheets("Resumen").Cells(1, 4)) = False Then
num1 = CStr(Format(Sheets("Resumen ").Cells(I, 2).Value, "#0;-#0;#0;#0"))
num2 = CStr(Format(Sheets("Resumen ").Cells(I, 3).Value, "#0;-#0;#0;#0"))
num3 = CStr(Format(Sheets("Resumen ").Cells(I, 4).Value, "#0.00;-#0.00;#0.00;#0.00"))
num4 = CStr(Format(Sheets("Resumen ").Cells(I, 5).Value, "#0.00;-#0.00;#0.00;#0.00"))
num5 = CStr(Format(Sheets("Resumen ").Cells(I, 6).Value, "#0.00;-#0.00;#0.00;#0.00"))
num6 = CStr(Format(Sheets("Resumen ").Cells(I, 7).Value, "#0.00;-#0.00;#0.00;#0.00"))
num7 = CStr(Format(Sheets("Resumen ").Cells(I, 8).Value, "#0.00;-#0.00;#0.00;#0.00"))
num8 = CStr(Format(Sheets("Resumen ").Cells(I, 9).Value, "#0.00;-#0.00;#0.00;#0.00"))
num9 = CStr(Format(Sheets("Resumen ").Cells(I, 10).Value, "#0.00;-#0.00;#0.00;#0.00"))
num10 = CStr(Format(Sheets("Resumen ").Cells(I, 11).Value, "#0.00;-#0.00;#0.00;#0.00"))
num11 = CStr(Format(Sheets("Resumen ").Cells(I, 12).Value, "#0.00;-#0.00;#0.00;#0.00"))
num12 = CStr(Format(Sheets("Resumen ").Cells(I, 13).Value, "#0.00;-#0.00;#0.00;#0.00"))
num13 = CStr(Format(Sheets("Resumen ").Cells(I, 14).Value, "#0.00;-#0.00;#0.00;#0.00"))
num14 = CStr(Format(Sheets("Resumen ").Cells(I, 15).Value, "#0.00;-#0.00;#0.00;#0.00"))
num15 = CStr(Format(Sheets("Resumen ").Cells(I, 16).Value, "#0.00;-#0.00;#0.00;#0.00"))
num16 = CStr(Format(Sheets("Resumen ").Cells(I, 17).Value, "#0.00;-#0.00;#0.00;#0.00"))
num17 = CStr(Format(Sheets("Resumen ").Cells(I, 18).Value, "#0.00;-#0.00;#0.00;#0.00"))
num18 = CStr(Format(Sheets("Resumen ").Cells(I, 19).Value, "#0.00;-#0.00;#0.00;#0.00"))
num19 = CStr(Format(Sheets("Resumen ").Cells(I, 20).Value, "#0;-#0;#0;#0"))
num20 = CStr(Format(Sheets("Resumen ").Cells(I, 21).Value, "#0;-#0;#0;#0"))
Sheets("Data ").Cells(f, 1).Value = Sheets("Resumen ").Cells(I, 1).Text
Sheets("Data ").Cells(f, 2).Value = num1
Sheets("Data ").Cells(f, 3).Value = num2
Sheets("Data ").Cells(f, 4).Value = num3
Sheets("Data ").Cells(f, 5).Value = num4
Sheets("Data ").Cells(f, 6).Value = num5
Sheets("Data").Cells(f, 7).Value = num6
Sheets("Data ").Cells(f, 8).Value = num7
Sheets("Data ").Cells(f, 9).Value = num8
Sheets("Data ").Cells(f, 10).Value = num9
Sheets("Data ").Cells(f, 11).Value = num10
Sheets("Data ").Cells(f, 12).Value = num11
Sheets("Data ").Cells(f, 13).Value = num12
Sheets("Data ").Cells(f, 14).Value = num13
Sheets("Data ").Cells(f, 15).Value = num14
Sheets("Data ").Cells(f, 16).Value = num15
Sheets("Data ").Cells(f, 17).Value = num16
Sheets("Data ").Cells(f, 18).Value = num17
Sheets("Data ").Cells(f, 19).Value = num18
Sheets("Data ").Cells(f, 20).Value = num19
Sheets("Data ").Cells(f, 21).Value = num20
f = f + 1
End If
Next I
Sheets("Data MPV").Activate
ActiveWorkbook.SaveAs Filename:="D:\" + Sheets("Resumen ").Cells(3, 1).Text + ".txt", FileFormat:=xlTextPrinter, CreateBackup:=False
'Cierra Libro
ActiveWorkbook.Close (False)
End Sub
RESULTADO
