Hey Forum Peeps,

I'm working on an automated document where I'm using content control to import the information from an XML into a Microsoft word document. I've hit a wall in developing codes when it comes to extracting a table and importing it /in/ a table format. I have developed coding that will extract a table from an XML and import it as a linearized table (NO graphic table. It appears like,

"Header: Information
Header: Information
Header: Information"

What I'm trying to do is discover the coding necessary to import the XML information into a graphic table with cells, but I'm not entirely sure what the codes are or where to put them in... Attached below is a sample of the linearized table codes. Any help with editing the code or tips of where to find good information to do so would be incredibly appreciated.

Thank you.

Public Sub RHTable(ByVal CCtag As String, ByVal xPath As String)

Dim curConControl As ContentControls
Set curConControl = ActiveDocument.SelectContentControlsByTag(CCtag)
Dim tableInfo As Word.Table
tablestring = ""
Dim xDoc As MSXML2.DOMDocument
Set xDoc = New MSXML2.DOMDocument

If Not xDoc.Load(xml) Then
Err.Raise xDoc.parseError.ErrorCode, , xDoc.parseError.reason
End If

Dim list As IXMLDOMNodeList
Set list = xDoc.SelectNodes(xPath)

Dim attr As IXMLDOMAttribute
Dim node As IXMLDOMNode
Dim childNode As IXMLDOMNode

For Each node In list

If node.HasChildNodes = True Then
For Each childNode In node.ChildNodes If childNode.HasChildNodes = True Then
For Each Child In childNode.ChildNodes
If Child.Text <> "" Then
If StrComp(Child.BaseName, "COLUMN_1", 1) = 0 Then
' Debug.Print Child.Text
tablestring = tablestring & Replace(Child.Text, "***********", "****")
Else
' Debug.Print Child.Text
tablestring = tablestring & ":" & Replace(Child.Text, "***********", "****")
End If
End If
Next Child
End If
' Debug.Print vbCrLf
tablestring = tablestring & vbCrLf
Next childNode
End If
Next node

With curConControl(1)
' Debug.Print Len(tablestring)
If Len(tablestring) > 2 Then
.Range.Text = tablestring
Else
ActiveDocument.Range(.Range.Start - 1, .Range.End + 2).Select
Selection.Delete
End If
End With
End Sub