Private Sub Command1_Click()
Dim xmlDoc As MSXML2.DOMDocument
Dim objRoot As MSXML2.IXMLDOMNode
Dim objChild As MSXML2.IXMLDOMNode
Dim objDetails As MSXML2.IXMLDOMNode
Dim objProcInst As MSXML2.IXMLDOMProcessingInstruction
'Create an XML document
' Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Set xmlDoc = New MSXML2.DOMDocument
'Create a root element and append it to the document
Set objRoot = xmlDoc.createElement("NEWAPPOINTMENTS")
xmlDoc.appendChild objRoot
'Create node for first appointment
Set objChild = xmlDoc.createElement("APPOINTMENT")
objRoot.appendChild objChild
'Add the details for first appointment
Set objDetails = xmlDoc.createElement("START")
objDetails.Text = "Code to fill start text node"
objChild.appendChild objDetails
Set objDetails = xmlDoc.createElement("END")
objDetails.Text = "Code to fill start end node"
objChild.appendChild objDetails
Set objDetails = xmlDoc.createElement("SUBJECT")
objDetails.Text = "Code to fill start subject node"
objChild.appendChild objDetails
'Create node for second appointment
Set objChild = xmlDoc.createElement("APPOINTMENT")
objRoot.appendChild objChild
'Add the details for second appointment
Set objDetails = xmlDoc.createElement("START")
objDetails.Text = "Code to fill second appointment start text node"
objChild.appendChild objDetails
Set objDetails = xmlDoc.createElement("END")
objDetails.Text = "Code to fill second appointment end node"
objChild.appendChild objDetails
Set objDetails = xmlDoc.createElement("SUBJECT")
objDetails.Text = "Code to fill second appointment subject node"
objChild.appendChild objDetails
'Add an XML processing instruction
'and insert it before the root element
Set objProcInst = xmlDoc.createProcessingInstruction("xml", "version='1.0'")
xmlDoc.insertBefore objProcInst, xmlDoc.childNodes(0)
'Save the XML file to the c directory
xmlDoc.save "c:\test.xml"
End Sub