How add a new OOXML node...
For the very good Authors of EXCEL 2007 VBA
The following VBA (Excel 07 macro language) code refers to a C:\MyFolder, where I extracted the OOXML parts of a (normal) Excel 2007 .xlsx file. The aim was the removal of the last relationship of \_rels\.rels xml file and it is regularly achieved.
. . . o m i s s i s . . .
Dim DocXml As DOMDocument
Dim NodesXML As IXMLDOMNodeList
Dim LenNodes As Integer
Set DocXml = New DOMDocument
DocXml.async = False
DocXml.Load ("C:\MyFolder\_rels\.rels")
Set NodesXml = DocXml.SelectNodes("//Relationship")
LNodes = NodesXml.Lenght '# of nodes
Dim LastNodo As IXMLDOMNode
Set LastNode = NodesXml(LNodes - 1)
MsgBox "Last Node:" & vbLf & LastNode.XML 'Regular indication
'An alternative:
Dim strLastNode
strLastNode = "//Relationship[" & (LNodes â 1) & "]"
Set LastNode = DocXml.SelectSingleNode(strLastNode)
MsgBox "Last Node:" & vbLf & LastNode.XML 'Regular indication, as before
LastNodo.ParentNode.RemoveChild LastNodo
DocXml.Save FileXML
. . . o m i s s i s . . .
But I would like better to ADD another relationship, e.g. which is needed for a customUI.xml of mine. I know it but I cannot anyway find the VBA code for this goal.
My attempts all start with something like this:
LastNodo.ParentNode.AppendChild ( ? ? ?, ? ? ? )
But all fail, I think chiefly because I ignore the exact syntax ( the question marks above) and what I have to do before this instruction in order to define the child node to be appended. The Help is generic and confusing, alas.
Is there some other way for this goal? And how is to be used?
Thanks
|