SHOTOKANKATANA
New member
- Local time
- Today, 13:42
- Joined
- Dec 4, 2021
- Messages
- 17
First time I post a question here so bare with me if I make a mistake and please do tell me if so. Let's start with a big thanks for this forum and all it's contributors, it's been really helpful to me. I'm building a database which has become quite complex over the last few months and I have been able to solve many issues I ran into along the way with posts from here, so thanks!
Okay so here it goes...
I need to be able to generate a SEPA XML file for banking use. It has to be an ISO 20022, PAIN 008, UTF8 file.
The information that needs to go into the SEPA XML file is loaded on a form and I'd like to generate the file with the click of a button. The button is already there and the other things the click event has to do are in place and working, I'm only missing the code to generate the actual file.
Let's say the form is named Form1, it has 2 subforms, Subform1 (single form) and Subform 2 (continuous form)
Subform 1 holds receivers info, and subform 2 holds the actual payment records.
How do I create the XML file with the info on Subform 1 and 2 implemented into it?
My VBA skills are not great, certainly not horrible either but this goes a bit over my head.
I found a post about this on another forum that has some code I think I can use but I'm not sure if it's complete and how I could implement my records into it.
Could I use this code, maybe alter it to my situation a bit, and implement some more code so the actual XML file holds the information from Subform 1 and 2?
Any help on this would be greatly appreciated, Thanks in advance!
Here is the code:
Okay so here it goes...
I need to be able to generate a SEPA XML file for banking use. It has to be an ISO 20022, PAIN 008, UTF8 file.
The information that needs to go into the SEPA XML file is loaded on a form and I'd like to generate the file with the click of a button. The button is already there and the other things the click event has to do are in place and working, I'm only missing the code to generate the actual file.
Let's say the form is named Form1, it has 2 subforms, Subform1 (single form) and Subform 2 (continuous form)
Subform 1 holds receivers info, and subform 2 holds the actual payment records.
How do I create the XML file with the info on Subform 1 and 2 implemented into it?
My VBA skills are not great, certainly not horrible either but this goes a bit over my head.
I found a post about this on another forum that has some code I think I can use but I'm not sure if it's complete and how I could implement my records into it.
Could I use this code, maybe alter it to my situation a bit, and implement some more code so the actual XML file holds the information from Subform 1 and 2?
Any help on this would be greatly appreciated, Thanks in advance!
Here is the code:
Code:
Dim xmlDom As MSXML2.DOMDocument60
Dim xmlspacename As MSXML2.IXMLDOMElement
Dim xmlVersion As MSXML2.IXMLDOMProcessingInstruction
Dim xslStylesheet As MSXML2.IXMLDOMProcessingInstruction
Set xmlDom = New MSXML2.DOMDocument60
Set xmlVersion = xmlDom.createProcessingInstruction("xml", "version='1.0' encoding= 'UTF-8'")
xmlDom.appendChild xmlVersion
Set xmlspacename = xmlDom.createElement("Document")
xmlDom.appendChild xmlspacename
xmlDom.documentElement.setAttribute "xmlns", "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"
xmlDom.documentElement.setAttribute "xmlns:xsd", "http://www.w3.org/2001/XMLSchema"
xmlDom.documentElement.setAttribute "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"
'****RAIZ DEL MENSAJE
'Creando elemento raiz [1..1]_0
Dim xmlrootnode As IXMLDOMElement
Set xmlrootnode = xmlDom.createElement("CstmrCdtTrfInitn")
xmlspacename.appendChild xmlrootnode
'*****CABECERA
' Creando 1_0_cabecera [1..1]_0
Dim cabecera As IXMLDOMElement
Set cabecera = xmlDom.createElement("GrpHdr")
xmlrootnode.appendChild cabecera
MsgBox "Ok"
' Saves XML data to disk.
xmlDom.Save ("c:\temp\andrew.xml")
Last edited: