Sub ExportToXML()
Dim xmlDoc As Object
Dim xmlRoot As Object
Dim xmlSheet As Object
Dim xmlRow As Object
Dim xmlCell As Object
Dim ws As Worksheet
Dim r As Range
Dim c As Range
Dim xmlFilePath As String
' Créer un nouveau document XML
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
Set xmlRoot = xmlDoc.createElement("Workbook")
xmlDoc.appendChild xmlRoot
' Parcourir chaque feuille de calcul
For Each ws In ThisWorkbook.Worksheets
Set xmlSheet = xmlDoc.createElement("Worksheet")
xmlSheet.setAttribute "name", ws.Name
xmlRoot.appendChild xmlSheet
' Parcourir chaque ligne dans la feuille de calcul
For Each r In ws.UsedRange.Rows
Set xmlRow = xmlDoc.createElement("Row")
xmlSheet.appendChild xmlRow
' Parcourir chaque cellule dans la ligne
For Each c In r.Cells
Set xmlCell = xmlDoc.createElement("Cell")
xmlCell.setAttribute "column", c.Column
xmlCell.Text = c.Text
xmlRow.appendChild xmlCell
Next c
Next r
Next ws
' Spécifier le chemin du fichier XML de sortie
xmlFilePath = ThisWorkbook.Path & "\ExportedWorkbook.xml"
' Enregistrer le document XML
xmlDoc.Save xmlFilePath
MsgBox "Le fichier XML a été exporté vers : " & xmlFilePath
End Sub