excelxsdfile-conversionxlm

Converting excel to specific type of XMLformat?


I have an excel file and I need to convert to XMLformat. However, it needs to be in one of these formats according to the french audit department:

My question is: Is it possible to convert excel format into one of these XML enconding formats? Sorry if it is a simple question, but I have no experience with excel formatting. Thank you very much!

Link in french: https://www.impots.gouv.fr/portail/les-comptabilites-informatisees

Link to the formats:

https://www.impots.gouv.fr/portail/files/media/1_metier/2_professionnel/a47a-i-viii-7.xsd

https://www.impots.gouv.fr/portail/files/media/1_metier/2_professionnel/a47a-i-vii-1.xsd

https://www.impots.gouv.fr/portail/files/media/1_metier/2_professionnel/a47a-i-viii-5.xsd

https://www.impots.gouv.fr/portail/files/media/1_metier/2_professionnel/a47a-i-viii-3.xsd


Solution

  • I wrote an abstract code, but you can put your hand in, to suite your needs

    Private Sub CommandButton3_Click()
    
    
    NRows = Sheet1.UsedRange.Rows.Count
    NCols = Sheet1.UsedRange.Columns.Count
    MsgBox NRows & "-" & NCols
    XMLStr = "<Root>" & vbCr
    For i = 2 To NRows
        XMLStr = XMLStr & "<Row>" & vbCr
        For j = 1 To NCols
             XMLStr = XMLStr & "<Col>" & Cells(i, j) & "</Col>" & vbCr
        Next
        XMLStr = XMLStr & "</Row>" & vbCr
    Next
    XMLStr = XMLStr & "</Root>" & vbCr
    
    'writting string to xml file
    
    Dim myFile As String
    myFile = Application.DefaultFilePath & "\myXML.xml"
    Open myFile For Output As #1
    Write #1, XMLStr
    Close #1
    End Sub