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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| Sub Extraire_noms_fichiers_milieux_pdf()
Dim Chemin As String, Fichier As Variant
Dim Ligne As Long, filename1 As String, filename2 As String, filename3 As String, html_milieu As String
Dim filename5 As String, filename6 As String, filename7 As String, html_solution As String
Dim fin_liste_milieux As Long, debut_liste_solutions, fin_liste_solutions As Long
Dim i As Long, derlig As Long, tabl
Ligne = 1
Chemin = "Z:\Programmation\Excel\tmp_fichiers\"
If Right(Chemin, 1) <> "\" Then Chemin = Chemin & "\"
'Extraire nom de fichiers Milieux
Fichier = Dir(Chemin & "milieu*.pdf", vbArchive)
'Ecriture "en-tete" du fichier html dans tableau
Sheets("Milieux_Solutions_html").Activate
ActiveSheet.Range("A" & Ligne) = "<html><head><title>Milieux</title><body>"
Ligne = Ligne + 1
'Ecriture "en-tete" suite de la partie "Milieux" dans tableau
ActiveSheet.Range("A" & Ligne) = "<p><center><b>Milieux</b></center><br/><br/>"
Do While Fichier <> ""
Ligne = Ligne + 1
filename1 = Fichier
filename2 = Replace(filename1, "milieu_", "")
filename3 = Replace(filename2, ".pdf", "")
html_milieu = "<center><a href=" + Chr(34) + filename1 + Chr(34) + ">" + filename3 + "</a></center>"
'Ecriture html dans tableau
ActiveSheet.Range("A" & Ligne) = html_milieu
Fichier = Dir
Loop
fin_liste_milieux = Ligne
'Ecriture "fin" de la partie milieu dans tableau
Ligne = Ligne + 1
ActiveSheet.Range("A" & Ligne) = "</p>"
'End Sub
'extraire_noms_fichiers_solutions()
Ligne = Ligne + 1
Chemin = "Z:\Programmation\Excel\tmp_fichiers\"
If Right(Chemin, 1) <> "\" Then Chemin = Chemin & "\"
Fichier = Dir(Chemin & "solution*.pdf", vbArchive)
'Ecriture "en-tete" du fichier html dans tableau
ActiveSheet.Range("A" & Ligne) = "<br/><p><center><b>Solutions</b></center><br/><br/>"
Do While Fichier <> ""
Ligne = Ligne + 1
filename5 = Fichier
filename6 = Replace(filename5, "solution_", "")
filename7 = Replace(filename6, ".pdf", "")
html_solution = "<center><a href=" + Chr(34) + filename5 + Chr(34) + ">" + filename7 + "</a></center>"
'Ecrire html dans tableau
ActiveSheet.Range("A" & Ligne) = html_solution
Fichier = Dir
Loop
fin_liste_solutions = Ligne
Ligne = Ligne + 1
ActiveSheet.Range("A" & Ligne) = "</p>"
Ligne = Ligne + 1
ActiveSheet.Range("A" & Ligne) = "</body></html>"
'MsgBox ("milieu" & fin_liste_milieux & "solutions" & fin_liste_solutions)
'Trier les lignes milieu
debut_liste_milieux = 3
Range(Cells(3, 1), Cells(fin_liste_milieux, 1)).Select
ActiveWorkbook.Worksheets("Milieux_Solutions_html").Sort.SortFields.Clear
'Key:=Range("A" & JOURS.Cells(1) & ":A" & JOURS.Cells.Count)
ActiveWorkbook.Worksheets("Milieux_Solutions_html").Sort.SortFields.Add Key:=Range("A" & debut_liste_milieux), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Milieux_Solutions_html").Sort
.SetRange Range(Cells(3, 1), Cells(fin_liste_milieux, 1))
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Trier les lignes solutions
debut_liste_solutions = (fin_liste_milieux + 3)
Range(Cells(debut_liste_solutions, 1), Cells(fin_liste_solutions, 1)).Select
ActiveWorkbook.Worksheets("Milieux_Solutions_html").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Milieux_Solutions_html").Sort.SortFields.Add Key:=Range("A" & debut_liste_solutions), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Milieux_Solutions_html").Sort
.SetRange Range(Cells(debut_liste_solutions, 1), Cells(fin_liste_solutions, 1))
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
' Ecrire dans un fichier html
derlig = Range("A" & Rows.Count).End(xlUp).Row
tabl = Range("A1:A" & derlig)
Open "Z:\Programmation\Excel\tmp_fichiers\milieux.html" For Output As #1
For i = 1 To UBound(tabl, 1)
If tabl(i, 1) <> "" Then
Print #1, tabl(i, 1)
End If
Next
Close #1
End Sub |
Partager