exporter automatiquement excell en text

faneva

XLDnaute Nouveau
Bonjour,
je voudrais exporter automatiquement mes fichiers excell en fichiers text et avec séparateur ";" vers un chemin précis
Merci de votre aide
 

faneva

XLDnaute Nouveau
Re : exporter automatiquement excell en text

je propose le macro suivant
Code:
Sub TEXTE()
Dim nim, l, c, lignetot, coltot, derlin As Long
Dim entete As String
Dim tablo As Variant
coltot = ActiveSheet.UsedRange.Columns.Count
lignetot = ActiveSheet.UsedRange.Rows.Count
tablo = Range(Cells(1, 1), Cells(lignetot, coltot)).Value
l = 1
c = 1

nim = Cells(l, 1).Value
entete = Cells(1, c)


Do While entete <> ""
    Do While nim <> ""
            If IsNumeric(nim) Then
                'For l = LBound(tablo) To UBound(tablo)
                
    
                Open "D:\essai.txt" For Append As Cells(l, c).Value

                Print #Cells(l, c).Value,

                'Next
                
            End If
            Close #tablo(l, c)
            l = l + 1
            nim = Cells(l, 1).Value
    Loop
Loop
    c = c + 1


End Sub
[code]
mais il affiche depassement de capacité sur open
Merci de votre aide
 

kjin

XLDnaute Barbatruc
Re : exporter automatiquement excell en text

Re,
Code:
Sub ExportTxt()
Dim Nb As Integer, Tablo, Texte As String
Tablo = Range("A1:J5").Value
Nb = FreeFile
Open "D:\essai.txt" For Append As #Nb 'Append s'il faut conserver les données existantes, sinon OutPut
For i = 1 To UBound(Tablo, 1)
    For j = 1 To UBound(Tablo, 2)
    Texte = Texte & Tablo(i, j) & ";"
    Next
    Print #Nb, Left(Texte, Len(Texte) - 1)
    Texte = ""
Next
Close #Nb
End Sub
A+
kjin
 

Discussions similaires

Réponses
15
Affichages
579
Réponses
2
Affichages
282

Statistiques des forums

Discussions
312 429
Messages
2 088 351
Membres
103 824
dernier inscrit
frederic.marien@proximus.