Salut !

Voila je voudrais, j'ai quelques connaissances de VB 6 mais en VBA je suis perdu avec les range et tout
Mon problème est simple je pense (pour vous les experts !). on me demande d'exporter un tableau en XML...

Voici la structure
Message

Layer

Direction

Channel Type

Message | Layer | Direction | Channel Type
-------------------------------------------
Packet AR | RLC_MAC | Uplink | PCCH_MSG

...
Je voudrais faire un truc du genre :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
<network>
    <message direction="Uplink">
         <id>Packet AR</id>
         <layer>RLC_MAC</layer>
         <channel>PCCH_MSG</channel> 
    </message>
</network>
J'ai fais ca pour l'instant, mais bien sûr ca ne fonctionne pas, j'ai du me fourvoyer dans l'utilisation des ranges...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Sub export2XML()
    Dim newrange As Range
    Dim cell As Range
    Dim filename As Variant
    Dim retVal As Variant
    Dim suffix As String
    suffix = ""
    Dim iCol As Long
    Dim Col_id As String
    Dim colRange As Range
    Dim fp As Integer
    fp = FreeFile
    filename = ThisWorkbook.Path & "\export.txt"
    Open filename For Output As #fp
    For iCol = 1 To 4
        Set newrange = Intersect(Cells.Columns(iCol), ActiveSheet.UsedRange)
        Col_id = Left(Cells(1, iCol).Address(0, 0), _
          Len(Cells(1, iCol).Address(0, 0)) - 1)
        For Each cell In newrange     'newrange
            If Trim(cell.Text) <> "" Then
                Print #1, cell.Text & suffix
            End If
        Next cell
    Next iCol
  Close #1
End Sub
Merki !!!
+++
Ju