Saludos nuevamente
el objetivo de la sig. macro listada es que me genere un
archivo de texto con ciertos espacios determinados hasta
ahora lo genera asi:
01/04/04 123456 11560.80 000 MOVTO ABRIL
02/04/04 123457 1230.60 000 MOVTO ABRIL
03/04/04 963145 950.80 000 MOVTO ABRIL
y lo necesito asi:
01/04/04 123456 11560.80 000 MOVTO ABRIL
02/04/04 123457 1230.60 000 MOVTO ABRIL
03/04/04 963145 950.80 000 MOVTO ABRIL
AGRADEZCO desde ya su apoyo..
Sub ExportarDelimitado()
Dim HojaPol As Worksheet
Dim intFich As Integer, lngNumReg As Long, strCad As
String, strCar As String * 1
Dim lngContL As Long, intContC As Integer, N As Long
Set HojaPol = Worksheets("polcont") 'Hoja donde están
los datos
intFich = FreeFile(0)
lngContL = 1 'Se empezará a exportar en la fila 2 (se
entiende que la 1ª es de títulos)
intContC = 6 'Se exportarán las columnas 1 a 6
If Dir("C:\Fichero.txt") <> "" Then Kill
("C:\Fichero.txt") 'Si ya existe C:\Fichero.txt, lo borra.
Open "C:\Fichero.txt" For Random As intFich Len = 1
While Not IsEmpty(HojaPol.Cells(lngContL, 1))
For N = 1 To intContC
strCad = strCad & Format(HojaPol.Cells
(lngContL, N), HojaPol.Cells(lngContL, N).NumberFormat)
& " "
Next N
strCad = Left(strCad, Len(strCad) - 1) &
vbNewLine 'Para quitar el último delimitador por la
derecha y añadir el salto de línea
For N = 1 To Len(strCad)
strCar = Mid(strCad, N, 1)
lngNumReg = lngNumReg + 1
Put intFich, lngNumReg, strCar
Next N
lngContL = lngContL + 1
strCad = ""
Wend
Close intFich
Set HojaPol = Nothing
End Sub
Leer las respuestas