Unsure of the best way to bind a a drop-down list Content Control to an XML file properly: all I'm getting is the first item.
I'm assuming I'll have to iterate through the XML document, count number of items, and then call the .Add
method on the control accordingly, but I'm not sure how to do that in VBA.
Here's what I have:
Dim ap As Document
Dim cnt As Integer
Set ap = ActiveDocument
cnt = ap.CustomXMLParts.Count + 1
ap.CustomXMLParts.Add
ap.CustomXMLParts(cnt).Load ("C:\test\Employees.xml")
Dim strXPath1 As String
strXPath1 = "/Employees/Employee/@name"
ActiveDocument.ContentControls(1).XMLMapping.SetMapping strXPath1
Which (as expected) gets the first name attribute; just not sure how best to populate a Content Control drop-down from an XML document (see XML document below):
<?xml version="1.0"?>
<Employees>
<Employee name="Joe Blow">
<Email>[email protected]</Email>
<Extension>201</Extension>
</Employee>
<Employee name="Bob Smith">
<Email>[email protected]</Email>
<Extension>202</Extension>
</Employee>
</Employees>