1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| Dim ligne_debut As Integer: Dim colonne_debut As Integer
Dim ligne_fin As Integer: Dim colonne_fin As Integer
Dim ligne_encours As Integer: Dim colonne_encours As Integer
Private Sub importer_Click()
Dim fichier_choisi As String
fichier_choisi = Application.GetOpenFilename("Text Files (*.log),*.log", , "Sélectionner les fichier log")
If (LCase(fichier_choisi) <> "Faux" And fichier_choisi <> "0") Then
liste_fichiers.AddItem (fichier_choisi)
End If
End Sub
Private Sub exporter_Click()
Dim nom_fichier As String
ligne_debut = 2: colonne_debut = 2
ligne_encours = ligne_debut: colonne_encours = colonne_debut
Cells.Clear
For i = 0 To liste_fichiers.ListCount - 1
lecture (liste_fichiers.List(i))
Next i
traitement
nom_fichier = Application.GetSaveAsFilename(fileFilter = "Text Files (*.txt),*.txt")
sortie.Value = nom_fichier
ecriture (nom_fichier)
End Sub
Private Sub fermer_Click()
End Sub
Private Sub lecture(fichier As String)
Dim depart As Integer, position As Integer
Dim texte As String, tampon As String
Open fichier For Input As #1
Do While Not EOF(1)
Line Input #1, texte
depart = 1: position = 1
Do While (position <> "0")
position = InStr(depart, texte, ";", 1)
If position = 0 Then
tampon = Mid(texte, depart)
Sheets("Import").Cells(ligne_encours, colonne_encours).Value = tampon
Exit Do
Else
tampon = Mid(texte, depart, position - depart)
End If
Sheets("Import").Cells(ligne_encours, colonne_encours).Value = tampon
depart = position + 1
colonne_encours = colonne_encours + 1
Loop
colonne_encours = colonne_debut
ligne_encours = ligne_encours + 1
Rem c est ici que ca se passe
rem c est ici que je placais mon Sheets.add , mais il me genere autant d'onglet que j ai de ligne dans mes fichiers
Loop
Close #1
End Sub |
Partager