Passer de VB.NET à VBA - XML via VB
Bonjour à tous,
Voici mon problème :
J'ai un fichier VB.Net qui fonctionne, cependant je dois le passer sous VBA et je n'y arrive pas. Je n'ai pas beaucoup de connaissance dans ce domaine.
Code:
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
| Imports System.Xml
Imports System
Imports System.Reflection
Module Module1
Private Property xmlDoc As Object
Dim nom As String
Dim compte As Integer
Dim nbp8 As Integer
Sub Main()
xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "false"
xmlDoc.Load("C:\Users\Joris\Desktop\Parametrage.xml")
Dim doc As XDocument = XDocument.Load("C:\Users\Joris\Desktop\Parametrage.xml")
For Each oElement In xmlDoc.getElementsByTagName("ROW")
If oElement.getAttribute("CODE_TYPE_PALETTE") = "P8" Then
For Each row In From element In doc.<DATAPACKET>.<ROWDATA>.<ROW>
Where element.@CODE_TYPE_PALETTE = "P8"
nbp8 = nbp8 + 1
row.Remove()
Next
End If
Next
xmlDoc = Nothing
MsgBox(nbp8)
doc.Save("C:\Users\Joris\Desktop\Parametrage.xml")
doc = Nothing
xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "false"
xmlDoc.Load("C:\Users\Joris\Desktop\Parametrage.xml")
compte = 0
For Each RowElement In xmlDoc.selectNodes("/DATAPACKET/ROWDATA/ROW")
compte = compte + 1
Next
MsgBox(compte)
xmlDoc = Nothing
End Sub
End Module |
Ce code fonctionne correctement, mais impossible de le passer sous VBA Excel 2010.
Avez-vous des idées ? svp
Je vous remercie,
A bientôt !
Tom