Quote:
Originally Posted by Guessed
Do you have an automated way to create the XML strings for charts created in other tools such as Excel or from screen captures? What method would you use to create these strings from a PNG filepath?
|
After running the macro, two mapped content controls will appear in your document.
These content controls are linked to the same node
Insert your picture into the "Picture" content control.
The string you are interested in will be in the Plain Text content control
Code:
Sub Two_Mapped_CC()
'
Dim oCC As Word.ContentControl
Dim oCustomPart As Office.CustomXMLPart
Dim orng As Range
Set oCustomPart = ActiveDocument.CustomXMLParts.Add("<ccMap><ccData></ccData></ccMap>")
Set oCC = ActiveDocument.ContentControls.Add(wdContentControlPicture)
With oCC
.Title = "Picture"
.XMLMapping.SetMapping "/ccMap/ccData[1]"
End With
Set orng = oCC.Range.Paragraphs(1).Range
With orng
.InsertParagraphAfter
.InsertParagraphAfter
.MoveEnd Unit:=wdCharacter, Count:=2
.Start = orng.End
End With
Set oCC = orng.ContentControls.Add(wdContentControlText)
With oCC
.Title = "Str"
.XMLMapping.SetMapping "/ccMap/ccData[1]"
End With
Set oCC = Nothing
Set oCustomPart = Nothing
Set orng = Nothing
Exit Sub
End Sub