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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
   |  
 
 Set racine_mdc = ParsDoc.documentElement
 
 
 For Each Noeud_md In racine_mdc.childNodes
 
  '***If Noeud_md.nodeName = "md" Then
 
  Select Case Noeud_md.nodeName
                Case "md"
 
 Set ListeEnfants_de_md = Noeud_md.childNodes
 
 
            For Each Noeud_mi In ListeEnfants_de_md
            '***If Noeud_mi.nodeName = "mi" Then
                Select Case Noeud_mi.nodeName
                        Case "mi"
            '*******************************Création d'une nouvelle feuille******************
            Worksheets.Add After:=Worksheets("IMPORT_XML")
           '****************************************************************************
           ActiveSheet.Cells(4, 1) = "Measurement Times"
           ActiveSheet.Cells(4, 2) = "Suspect values"
 
            ActiveSheet.Cells(4, 3) = "MOID"
            ActiveSheet.Cells(4, 4) = "COMPTEURS"
 
           Range("A4").Font.Bold = True
           Range("B4").Font.Bold = True
           Range("B4").Font.ColorIndex = 3
           Range("C4").Font.Bold = True
           Range("D4").Font.Bold = True
 
 intI = 7
 intK = 4
 intL = 7
 intR = 4
 intMT = 5
 
 'intrr = 6
 
             Set ListeEnfants_de_mi = Noeud_mi.childNodes
 
                    For Each Enfants_de_mi In ListeEnfants_de_mi
           ''' 'je peux incrémenter intR ici
            '''intR = 3
                        'If Enfants_de_mi.nodeName = "mts" Then
 
                        'date_mts = Enfants_de_mi.nodeTypedValue
                        'date_ok = Mid(date_mts, 1, 8) + " " + Mid(date_mts, 9, 2) + "h" + Mid(date_mts, 11, 2) + "mn"
                        'ActiveSheet.Cells(intI, 1).Value = date_ok
 
                        'End If
 
                       '***********partie  avec select***************
 
                    Select Case Enfants_de_mi.nodeName
 
                        Case "mts"
                                date_mts = Enfants_de_mi.nodeTypedValue
                                date_ok = Mid(date_mts, 1, 8) + " " + Mid(date_mts, 9, 2) + "h" + Mid(date_mts, 11, 2) + "mn"
                                ActiveSheet.Cells(intI, 1).Value = date_ok
 
                        Case "mt"
                            ActiveSheet.Cells(intMT, intK).Value = Enfants_de_mi.nodeTypedValue
                            intK = intK + 1
                     End Select
 
 
                        '*********************************************
 
 
                       ' If Enfants_de_mi.nodeName = "mt" Then
                       '  ActiveSheet.Cells(intMT, intK).Value = Enfants_de_mi.nodeTypedValue
                       ' intK = intK + 1
                      '  End If
 
                    'mettre en commentaire la fonction du dessous me fait gagner 5 sec/feuille xml
                      'ActiveSheet.Columns.AutoFit
 
                                '***If Enfants_de_mi.nodeName = "mv" Then
 
                                Select Case Enfants_de_mi.nodeName
 
                                            Case "mv"
 
                                Set Noeud_mv = Enfants_de_mi
 
                                Set ListeEnfants_de_mv = Noeud_mv.childNodes
 
                               '******************************************
 
                                    For Each Enfants_de_mv In ListeEnfants_de_mv
 
                                            '***If Enfants_de_mv.nodeName = "moid" Then
                                             '****ActiveSheet.Cells(intL, 3).Value = Enfants_de_mv.nodeTypedValue
                                             '***intL = intL + 1
                                             '****End If
 
                                             Select Case Enfants_de_mv.nodeName
 
                                                Case "moid"
                                                    ActiveSheet.Cells(intL, 3).Value = Enfants_de_mv.nodeTypedValue
                                                    intL = intL + 1
 
 
                                            '***If Enfants_de_mv.nodeName = "r" Then
                                            '***ActiveSheet.Cells(intL - 1, intR).Value = Enfants_de_mv.nodeTypedValue
                                            '***intR = intR + 1
                                            '***End If
 
                                                Case "r"
                                                    ActiveSheet.Cells(intL - 1, intR).Value = Enfants_de_mv.nodeTypedValue
                                                    intR = intR + 1
 
 
 
                                    '**************balise indiquant un fichier faux************
                                    '***If Enfants_de_mv.nodeName = "sf" Then
                                    '***ActiveSheet.Cells(intL - 1, 2).Value = Enfants_de_mv.nodeTypedValue
                                    '***Cells(intL - 1, 2).Font.ColorIndex = 3
                                    '***End If
                                    '****************************************************************
                                                Case "sf"
                                                    ActiveSheet.Cells(intL - 1, 2).Value = Enfants_de_mv.nodeTypedValue
                                                    Cells(intL - 1, 2).Font.ColorIndex = 3
 
                                    'mettre en commentaire la fonction du dessous me fait gagner 5 sec/feuille xml si desactivée
                                   'ActiveSheet.Columns.AutoFit
 
                                             End Select
 
                                    Next Enfants_de_mv
 
                                    '**********on reset  intR sur la ligne du dessous***********
                                    intR = 4
                                    '***************************************************************
                                '****End If
                            End Select
                    'pb quand on a fini la boucle dans les noeudenfant_mv on reste toujours sur le meme noeud_mi
                    Next Enfants_de_mi
 
 
 
                    intMT = intMT + 1
 
           '**** End If
           '***** le END IF du dessus c'est pour le noeud mi
                    End Select
            Next Noeud_mi
 
 
    '*** End If
    '*********pour le End If du dessus c'set pour le Noeud md
 
    '*************test 1 du moid pour créer les feuilles avec le moname****************
 
 
 
'Set racine_mdc = Nothing
'Set ListeEnfants_de_md = Nothing
'Set ListeEnfants_de_mi = Nothing
'Set ListeEnfants_de_mv = Nothing
'Set Liste_md = Nothing
'Set Enfants_de_md = Nothing
'Set Enfants_de_mi = Nothing
'Set Enfants_de_mv = Nothing
 
'Set Objet_Erreur = Nothing
 
'Set Noeud_md = Nothing
'Set Noeud_mi = Nothing
'Set Noeud_mts = Nothing
'Set Noeud_gp = Nothing
'Set Noeud_mt = Nothing
'Set Noeud_mv = Nothing
'Set Noeud_moid = Nothing
'Set Noeud_r = Nothing
 
     End Select
 Next Noeud_md
 
 
 Set ParsDoc = Nothing
 
 '******************test 2 du moid pour créer les feuilles avec le moname**************
 
 
 
'********************************FIN TRAITEMENT FICHIER XML*****************************
 
'****************Fonctions permettant de décharger les objets instanciés****************
 
 
'****************normalement pour vider la memoire des dom xml c'est ici
' j'ai modifié pour l'optim
 
 
'Set Noeud_line3 = Nothing
 
' on reactive la méthode
'Application.ScreenUpdating = True
Application.DisplayAlerts = True
 
End Sub |