Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 17th, 2007, 03:12 AM
Registered User
Join Date: Mar 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT Node add/delete aintvoguish XSLT 2 December 20th, 2007 03:01 AM
Use of Attributes prop.ty for a OOXML node Gianni Giaccaglini Excel VBA 1 September 24th, 2007 05:05 AM
Copying Source Node attributes to output node pvsat XSLT 2 November 3rd, 2005 09:46 AM
how to add or delete a node from an xml documnet sai XML 1 March 22nd, 2004 06:54 AM
Add node in ie treeview acko ASP.NET 1.x and 2.0 Application Design 0 January 28th, 2004 09:29 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.