Boostez vos compétences Excel avec notre communauté !
Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !
Sub GenXML()
Dim chemin As String
Dim ordre As String
ordre = Sheets("feuil1").Range("B2").Value
chemin = "D:\Monfichier" & " " & ".xml"
Nom_fichier = chemin
Dim intFic As Integer
intFic = FreeFile
Open Nom_fichier For Append As intFic
Print #intFic, "<ord>" & ordre & "</ord>"
Close intFic
End Sub
Print #intFic <num> votre valeur </num>
Print #intFic <des>votre valeur</des>
Print #intFic <mht>votre valeur</mht>
Print #intFic <tva>votre valeur</tva>
Print #intFic <ttc>votre valeur</ttc>
Sub GenXML()
Dim derligne As Integer
Dim Chemin, Fichier As String
'ordre = Sheets("feuil1").Range("B2").Value
derligne = Range("A" & Rows.Count).End(xlUp).Row
For Each cell In Range("A1:A" & derligne)
If Not IsEmpty(cell.Value) And IsNumeric(cell.Value) Then
Id_Fichier = Cells(cell.Row, (cell.Column) + 2).Value
Chemin = "C:\" & Id_Fichier & " " & ".xml"
Fichier = Chemin
Dim intFic As Integer
intFic = FreeFile
Open Fichier For Output As intFic
Print #intFic, "<?xml version="; 1#; "?>"
Print #intFic, "<DeclarationReleveDeduction xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">"
Print #intFic, "<identifiantFiscal>" & Sheets("DEDUC").Range("C2").Value & "</identifiantFiscal>"
Print #intFic, "<annee>" & Sheets("DEDUC").Range("C3").Value & "</annee>"
Print #intFic, "<periode>" & Sheets("DEDUC").Range("C4").Value & "</periode>"
Print #intFic, "<regime>" & Sheets("DEDUC").Range("C5").Value & "</regime>"
Print #intFic, "<releveDeductions>"
Print #intFic, "<rd>"
Print #intFic, "<ord>" & Cells(cell.Row, (cell.Column)).Value & "</ord>"
Print #intFic, "<num>" & Cells(cell.Row, (cell.Column) + 1).Value & "</num>"
Print #intFic, "<des>" & Cells(cell.Row, (cell.Column) + 2).Value & "</des>"
Print #intFic, "<mht>" & Cells(cell.Row, (cell.Column) + 3).Value & "</mht>"
Print #intFic, "<tva>" & Cells(cell.Row, (cell.Column) + 4).Value & "</tva>"
Print #intFic, "<ttc>" & Cells(cell.Row, (cell.Column) + 5).Value & "</ttc>"
Print #intFic, "<refF>"
Print #intFic, "<if>"; Cells(cell.Row, (cell.Column) + 6).Value; "</if>"
Print #intFic, "<nom>" & Sheets("DEDUC").Range("C7").Value & "</nom>"
Print #intFic, "<ice>" & Cells(cell.Row, (cell.Column) + 8).Value & "</ice>"
Print #intFic, "</refF>"
Print #intFic, "<tx>" & Cells(cell.Row, (cell.Column) + 9).Value& & "</tx>"
Print #intFic, "<mp>"
Print #intFic, "<id>" & " Pas trouvé dans les infos" & "</id>" ' à définir
Print #intFic, "</mp>"
Print #intFic, "<dpai>" & Cells(cell.Row, (cell.Column) + 11).Value & "</dpai>"
Print #intFic, "<dfac>" & "Pas trouvé dans les infos" & "</dfac>" ' à définir
Print #intFic, "</rd>"
Close intFic
End If
Next
End Sub
Sub GenXML()
Dim derligne As Integer
Dim Chemin, Fichier As String
derligne = Range("A" & Rows.Count).End(xlUp).Row
Chemin = "D:\FichierGen" & ".xml"
Fichier = Chemin
Dim intFic As Integer
intFic = FreeFile
Open Fichier For Output As intFic
Print #intFic, "<?xml version="; 1#; "?>"
Print #intFic, "<DeclarationReleveDeduction xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">"
Print #intFic, "<identifiantFiscal>" & Sheets("DEDUC").Range("C2").Value & "</identifiantFiscal>"
Print #intFic, "<annee>" & Sheets("DEDUC").Range("C3").Value & "</annee>"
Print #intFic, "<periode>" & Sheets("DEDUC").Range("C4").Value & "</periode>"
Print #intFic, "<regime>" & Sheets("DEDUC").Range("C5").Value & "</regime>"
Print #intFic, "<releveDeductions>"
For Each cell In Range("A1:A" & derligne)
If Not IsEmpty(cell.Value) And IsNumeric(cell.Value) Then
Print #intFic, "<rd>"
Print #intFic, "<ord>" & Cells(cell.Row, (cell.Column)).Value & "</ord>"
Print #intFic, "<num>" & Cells(cell.Row, (cell.Column) + 1).Value & "</num>"
Print #intFic, "<des>" & Cells(cell.Row, (cell.Column) + 2).Value & "</des>"
Print #intFic, "<mht>" & Cells(cell.Row, (cell.Column) + 3).Value & "</mht>"
Print #intFic, "<tva>" & Cells(cell.Row, (cell.Column) + 4).Value & "</tva>"
Print #intFic, "<ttc>" & Cells(cell.Row, (cell.Column) + 5).Value & "</ttc>"
Print #intFic, "<refF>"
Print #intFic, "<if>"; Cells(cell.Row, (cell.Column) + 6).Value; "</if>"
Print #intFic, "<nom>" & Sheets("DEDUC").Range("C7").Value & "</nom>"
Print #intFic, "<ice>" & Cells(cell.Row, (cell.Column) + 8).Value & "</ice>"
Print #intFic, "</refF>"
Print #intFic, "<tx>" & Cells(cell.Row, (cell.Column) + 9).Value& & "</tx>"
Print #intFic, "<mp>"
Print #intFic, "<id>" & " Pas trouvé dans les infos" & "</id>" ' à définir
Print #intFic, "</mp>"
Print #intFic, "<dpai>" & Cells(cell.Row, (cell.Column) + 11).Value & "</dpai>"
Print #intFic, "<dfac>" & Cells(cell.Row, (cell.Column) + 12).Value & "</dfac>" ' à définir
Print #intFic, "</rd>"
End If
Next
end sub
Close intFic
Bonjour le Forum
Bonjour max.lander
Vraiment, merci beaucoup pour votre aide. Votre code je l'ai appliqué à mon fichier d'origine (après quelques modifications)
J'ai même affecté la macro à un bouton sur ma feuille, et ça marche à merveille.
Toutefois, j'ai encore quelque chose à vous demander.
Sur le fichier généré, la derniere ligne de mon tableau ne s'affiche pas en entier, seulement jusqu'à la colonne 8. Je ne sais pas pourquoi, pourtant toutes les autres lignes s'affichent en entier.
J'ai sur mon fichier une dernière ligne qui affiche le total HT;le total de la TVA et le total TTC. Comment pourrai-je générer cette ligne dans mon fichier XML.
Pour l'enregistrement du fichier XML généré, y a-t-il un moyen pour que la macro me propose de nommer ce fichier et de l'enregistrer là où je veux.
Dans tous les cas, je vous remercie beaucoup, et je remercie beaucoup ce forum qui m'a tant appris depuis mon adhésion en 2006.
Bonne fin de journée à vous et à tout le monde
We use cookies and similar technologies for the following purposes:
Est ce que vous acceptez les cookies et ces technologies?
We use cookies and similar technologies for the following purposes:
Est ce que vous acceptez les cookies et ces technologies?