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
| Imports System.IO
Module Module1
Sub Main()
Dim monStreamReader As New StreamReader("C:\Documents and Settings\tanner\Desktop\liste.txt") 'Stream pour la lecture
Dim ligne As String ' Variable contenant le texte de la ligne
Dim test As String
Dim excel As New Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim Li As Long
Dim Li2 As Long
Dim tmp As Double
Dim x As String
x = Chr(66)
Li = 1
Li2 = 1
excel.Visible = True 'la fenêtre excel est visible
wb = excel.Workbooks.Add(1) 'on ouvre un classeur dans excel
ws = wb.Worksheets(1) 'on ouvre une feuille dans le classeur excel
wb.Sheets("Feuil1").Select() 'on séléctionne la feuille nommé "Feuil1"
wb.Sheets("Feuil1").Name = "Droits sur Y" 'on renomme la feuil1 en Alloga
excel.Visible = True 'la fenêtre excel est visible
Do
ligne = monStreamReader.ReadLine
test = ligne.Chars(0)
MsgBox(x)
If test = "Y" Then
ws.Range("A" & Li).Value = ligne
Li = Li + 1
Else
ws.Range(x + "1").Value = ligne
x = Chr(66 + Li2)
Li2 = Li2 + 1
End If
Loop Until ligne Is Nothing
wb.SaveAs("H:\droits Y\Liste.xls") 'Enregistrement du fichier
monStreamReader.Close()
End Sub
End Module |
Partager