View Single Post
 
Old 08-17-2020, 06:50 AM
Boris_R Boris_R is offline Windows Vista Office 2010 32bit
Novice
 
Join Date: Oct 2015
Posts: 6
Boris_R is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
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
Reply With Quote