In this tutorial (and many others), there’s an integer in the CustomXMLParts object collection Load method that I can’t find an explanation for. The Word 2007 VBA Reference doesn’t seem to list the Load method either:
''# Load CustomerData.xml file
ActiveDocument.CustomXMLParts.Add
ActiveDocument.CustomXMLParts(4).Load ("c:\CustomerData.xml")
What does the 4 represent?
There are always three built-in CustomXMLParts in every .docx (created by Word 2007/2010 – not necessarily a .docx created by the Open XML SDK). Namely:
So
4here just means, after you’ve doneActiveDocument.CustomXMLParts.Addto add a fourth one “get the fourth one”. If you had more, you would just use the next available index number. Instead of4, I’d probably just use this instead: