Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-09-2024, 07:36 AM
Omar2008 Omar2008 is offline Convert XML to Word(Content Control) Windows 10 Convert XML to Word(Content Control) Office 2013
Novice
Convert XML to Word(Content Control)
 
Join Date: Feb 2024
Location: Lima Perú
Posts: 6
Omar2008 is on a distinguished road
Default Convert XML to Word(Content Control)

Good morning:
I am trying to convert XML file into Content Controls (Word)
Each record in different pages

XML file D:\Ex03Rev1.xml (zip file)
The prototype word file with the content controls is:
D:\Ex05.docx which which has 3 current custom XML parts
attachment: ("Ex05 current customs XML parts.png")

Win 2010 & Office 2013 with Ms XML 6.0
attachment: ("Ex05macro xml 6.png")

The code is in Ex05macro.docx
The code can not add xml part to the word file, then the following is not possible (link each record to content control
By other side, my understanding of XML 6.0 is limited. I don't know where, in the code, the number 4 corresponding to the new custom xml should go.

Please your help
thank
Omar

Sub Ex05macro()
' Dim xmlDoc As MSXML2.DOMDocument60
' Set xmlDoc = New MSXML2.DOMDocument60
' xmlDoc.Load ("d:\Ex03Rev1.xml")
' xmlDoc.async = False

' Dim docXML As IXMLDOMNode ' Define miNodo como IXMLDOMNode para la iteración
'Set docXML = New MSXML2.DOMDocument60

'Set docXLM = GetXMLDocument()

Dim myDoc As Document
Set myDoc = Documents.Open("d:\Ex05.docx")
myDoc.CustomXMLParts.Add
myDoc.CustomXMLParts(4).Load ("d:\Ex03Rev1.xml")
Debug.Print myDoc.CustomXMLParts(4).Errors
' For Each miNodo In xlmDoc.SelectNodes("//RECORD")

' myDoc.Selection.InsertBreak Type:=wdPageBreak
Dim strXPath As String
strXPath = "/RECORD/ID"
myDoc.ContentControls(1).XMLMapping.SetMapping strXPath
strXPath = "/RECORD/ONR"


myDoc.ContentControls(2).XMLMapping.SetMapping strXPath
strXPath = "/RECORD/TAREA"
myDoc.ContentControls(3).XMLMapping.SetMapping strXPath
strXPath = "/RECORD/RECURSOS"
myDoc.ContentControls(4).XMLMapping.SetMapping strXPath
strXPath = "/RECORD/PRIORIDAD"
myDoc.ContentControls(5).XMLMapping.SetMapping strXPath
strXPath = "/RECORD/AERODROMO"
myDoc.ContentControls(6).XMLMapping.SetMapping strXPath
strXPath = "/RECORD/ESTATUS"
myDoc.ContentControls(7).XMLMapping.SetMapping strXPath
' Next miNodo
myDoc.SaveAs "d:\Ex05ONR.docx"
myDoc.Close
' Set xmlDoc = Nothing
End Sub
Attached Images
File Type: png Ex05 current customs XML parts.png (49.1 KB, 12 views)
File Type: png Ex05macro xml 6.png (16.1 KB, 12 views)
Attached Files
File Type: docx Ex05.docx (20.3 KB, 3 views)
File Type: docm Ex05macro.docm (17.7 KB, 2 views)
File Type: zip Ex03Rev1.zip (741 Bytes, 3 views)
Reply With Quote
 



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
Convert XML to Word(Content Control) 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
Convert XML to Word(Content Control) Content Control Dropdowns - How to duplicate the content control and allow a second choice ashleyf Word VBA 2 03-19-2020 09:11 AM
Convert XML to Word(Content Control) Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
Convert XML to Word(Content Control) Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft