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
| Attribute VB_Name = "Module2"
Sub textfile9()
Dim fs As Object, a As Object, s As String, s1 As String, s2 As String, s3 As String, i As Integer, j As Integer
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\test2.txt", True)
If Not IsEmpty(Cells(7, 2)) Then
s = s & "hostname" & " " & Cells(7, 2)
End If
If Not IsEmpty(Cells(7, 3)) And Not IsEmpty(Cells(7, 4)) Then
s1 = s1 & "ip address " & " " & Cells(7, 3) & " " & Cells(7, 4) & Chr(13) & Chr(10)
End If
i = 1
While Not IsEmpty(Cells(10, i))
While Not IsEmpty(Cells(11, i))
'Chr(13) & Chr(10) POUR LE SAUT DE LIGNE
'chr(9) pour la tabulation
s2 = s2 & Cells(10, i) & " " & Chr(13) & Chr(10) & Chr(9)
s2 = s2 & "name" & " " & Cells(11, i) & " " & Chr(13) & Chr(10) & Chr(9)
s2 = s2 & "ip address" & " " & Cells(12, i) & " " & Cells(13, i) & Chr(13) & Chr(10) & Chr(9)
s2 = s2 & "tagged" & " " & Cells(14, i) & Chr(13) & Chr(10) & Chr(9)
s2 = s2 & "untagged" & " " & Cells(15, i) & Chr(13) & Chr(10) & Chr(9)
s2 = s2 & "qos" & " " & "priority" & " " & Cells(16, i) & Chr(13) & Chr(10) & Chr(9)
i = i + 1
Wend
Wend
a.WriteLine s
a.WriteLine s1
a.WriteLine s2
a.WriteLine s3
a.Close
End Sub
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)
objWorkbook.SaveAs Chemin & "D:\Documents\ksadki\Desktop\industrialisation.xls"
''''''''Choix du matériel'''''''''''''''
materiel = InputBox("Entrez le matériel à configurer", "Choix de matériel","procurve")
if materiel= "procurve" then
''''''''''''Saisie des donnée pour Input:
switch = InputBox("Entrez le nom du switch:", "Switch name","")
ip = InputBox("Entrez l'adresse ip du Switch:", "ip address","")
gateway = InputBox("Entrez la passerelle", "gateway default","")
objWorksheet.Cells(6,1) = "Matériel"
objWorksheet.Cells(6,2) = "Nom du Switch"
objWorksheet.Cells(6,3) = "Ip Address du Switch"
objWorksheet.Cells(6,4) = "Default Gateway"
objExcel.Cells(7, 1).Value = materiel
objExcel.Cells(7, 2).Value = switch
objExcel.Cells(7, 3).Value = ip
objExcel.Cells(7, 4).Value = gateway
end if |