Quote:
Originally Posted by Guessed
Note that the 'image' file type is actually a string. You won't be able to include a PNG image in a text only format which is necessary for xml.
|
Here is some sample code to insert an image using XML mapping.
After running the code, a "Red Square" will appear in the document
Code:
Sub Add_Picture()
Dim oCC As Word.ContentControl
Dim oCustomPart As Office.CustomXMLPart
Set oCC = ActiveDocument.ContentControls.Add(wdContentControlPicture)
Set oCustomPart = ActiveDocument.CustomXMLParts.Add("<ccMap><ccData>iVBORw0KGgoAAAANSUhEUgAAADAAAAAmCAIAAAAN749WAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAScwAAEnMBjCK5BwAAAHNJREFUWEftmLEJwDAMBJU9Umb/zbKDE1BjjLkukeCMum+e86nRcZ9XlHpPoVITpdq832UhMKQPoW82bxVmS8hC6ZaEZhV0iFZDQhIiApTrkISIAOU6JCEiQLkOSYgIUK5DEiIClHd26K8zTZ/rh4Ty2DAAkMHKNHSz0cwAAAAASUVORK5CYII=</ccData></ccMap>")
With oCC
.Title = "Picture"
.XMLMapping.SetMapping "/ccMap/ccData[1]"
End With
Exit Sub
End Sub