![]() |
|
#5
|
|||
|
|||
|
I have not previously worked with custom xml parts with multiple records, so this has been a fun challenge.
The following code should get you most of the way there, though I can't guarantee that it will work in Office 2013: Code:
Sub Ex05macro()
Dim myDoc As Document: Set myDoc = Documents.Add
Dim myXPart As CustomXMLPart: Set myXPart = myDoc.CustomXMLParts.Add
Dim xNode As CustomXMLNode, xChild As CustomXMLNode
Dim cc As ContentControl
With myXPart
.Load ("D:\Ex03Rev1.xml")
For Each xNode In .DocumentElement.ChildNodes
If xNode.HasChildNodes Then
For Each xChild In xNode.ChildNodes
With xChild
If Not .BaseName = "#text" Then
Set cc = myDoc.ContentControls.Add(Type:=wdContentControlText, Range:=myDoc.Characters.Last)
cc.XMLMapping.SetMapping .XPath
myDoc.Paragraphs.Add
End If
End With
Next xChild
myDoc.Characters.Last.InsertBreak WdBreakType.wdPageBreak
End If
Next xNode
End With
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adjust content antd line spacing in word table according to checkbox content control state | AVarg123 | Word VBA | 13 | 01-10-2024 03:36 PM |
Change Value of a Content Control based on the value of another content Control
|
jsc_msoffice | Word VBA | 2 | 05-21-2021 09:51 PM |
Content Control Dropdowns - How to duplicate the content control and allow a second choice
|
ashleyf | Word VBA | 2 | 03-19-2020 09:11 AM |
Clicking the selected Content Control checkbox returns wrong control in vba event
|
DougsGraphics | Word VBA | 2 | 06-24-2015 07:31 AM |
Deleting a table from a content control -- preserving the content control
|
BrainSlugs83 | Word Tables | 8 | 11-14-2013 03:06 AM |