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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
Sub traite_gtdb()
' déclarations
Dim TDS_file As Object
Dim M_objdoc As Word.Document
Set le_Dossier = ThisWorkbook.Sheets("Tests")
' instance de word
Set TDS_file = New Word.Application
'f_TDS = ThisWorkbook.Path & "\doc_testa\" & "CDS_05_005266 rev12.doc"
f_TDS = ThisWorkbook.Path & "\doc_testa\" & "GTDB.doc"
' ouvrir le fichier GTDB
'TDS_file.Visible = True
On Error Resume Next
Set M_objdoc = TDS_file.Documents.Open(f_TDS)
'initialisation
le_Dossier.Cells.Clear
le_Dossier.Cells(1, 1).Value = "Numero Test"
le_Dossier.Cells(1, 2).Value = "TITRE"
le_Dossier.Cells(1, 3).Value = "OVERVIEW"
le_Dossier.Cells(1, 4).Value = "PARAMETRE"
le_Dossier.Cells(1, 5).Value = "I/O"
le_Dossier.Cells(1, 6).Value = "FORMAT"
le_Dossier.Cells(1, 7).Value = "USE"
le_Dossier.Cells(1, 8).Value = "N° Diagram"
With Columns("G:G")
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
With Columns("C:C")
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
i_tab = 0
i_diag = 0
T_deb = Time
Ln = 2
N_para = M_objdoc.Paragraphs.Count
' analyse du document
For i_para = 1 To N_para ' voir 2278
le_style = M_objdoc.Paragraphs(i_para).Style
le_texte = M_objdoc.Paragraphs(i_para).Range.Text
' definition des filtres
' traitement titre 3 : nom et n° du test
pos = InStr(le_style, "Titre 3;H3")
If pos > 0 Then
Ln = Ln + 1
pos = InStr(le_texte, ": FF")
titre_test = Left(le_texte, pos - 1)
posi = Len(le_texte) - pos - 1
num_test = Right(le_texte, posi)
le_Dossier.Activate
le_Dossier.Cells(Ln, 1).Value = num_test '"Numero Test"
le_Dossier.Cells(Ln, 2).Value = titre_test '"TITRE"
pos = 0
End If
' titre 4 overview
pos_T = InStr(le_style, "Titre 4")
pos_l = InStr(le_texte, "Overview")
If pos_T > 0 And pos_l > 0 Then
descri_test = M_objdoc.Paragraphs(i_para + 2).Range.Text
le_Dossier.Cells(Ln, 3).Value = descri_test
pos_l = 0
End If
' tableau
pos = InStr(le_texte, "List of used variables")
If pos > 0 Then tab_val = True
is_tab = M_objdoc.Paragraphs(i_para).Range.Tables.Count
If is_tab > 0 And tab_val = True Then
n_l = M_objdoc.Paragraphs(i_para).Range.Tables(1).Rows.Count
For lg = 2 To n_l
Nom = M_objdoc.Paragraphs(i_para).Range.Tables(1).Cell(lg, 2)
famil = M_objdoc.Paragraphs(i_para).Range.Tables(1).Cell(lg, 3)
forma = M_objdoc.Paragraphs(i_para).Range.Tables(1).Cell(lg, 4)
desc = M_objdoc.Paragraphs(i_para).Range.Tables(1).Cell(lg, 5)
le_Dossier.Cells(Ln, "D").Value = Nom
le_Dossier.Cells(Ln, "E").Value = famil
le_Dossier.Cells(Ln, "F").Value = forma
le_Dossier.Cells(Ln, "G").Value = desc
Ln = Ln + 1
Next lg
tab_val = False
'i_para = i_para + Ln * 5
End If
' diagram
pos_l = InStr(le_texte, "diagram")
If pos_l > 1 Then
'Is_diag = M_objdoc.Paragraphs(i_para).Shapes.Count
End If
'fin de l'analyse
Next i_para
fin:
T_fin = Time
duree = T_fin - T_deb
le_temps = Format(duree, "h:m:s")
M_objdoc.Close
'Quitter l'application Word créée
TDS_file.Quit
'Un peu de ménage
Set TDS_file = Nothing
Set M_objdoc = Nothing
MsgBox le_temps
End Sub |
Partager