I'm using ArcGIS Desktop 10.6 and I'm creating an Add-in to simultaneously add text (textelement populated from user input) and an image (company logo). The issue i'm having is with the image. I know there is a pictureelement but I have no idea how to work with a stdole.IPictureDisperse so I'm trying to see if I can use a PictureMarkerSymbol but no luck.

System.Uri myPictureUri = new System.Uri(picUrl);
PictureMarkerSymbol picm = myPictureUri as PictureMarkerSymbol;
graphContainer.AddElement(picm as IElement, 0);

1 Answer 1


Below is some VBA that will add an image to the page layout, note this is a link to the image on the hard drive rather than embedding it into the map document. If you want it embedded simply adjust IPictureElement5.SavePictureInDocument Property.

Public Sub AddPictureToLayout()
    ' Get document
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument

    ' Load JPG image into Element
    Dim pPictureElement5 As IPictureElement5
    Set pPictureElement5 = New JpgPictureElement
    pPictureElement5.ImportPictureFromFile "C:\Scratch\myPicture.JPG"

    ' Create an envelope in PAGE units and assign to geometry
    Dim pEnvelope As IEnvelope
    Set pEnvelope = New Envelope
    pEnvelope.XMax = 12
    pEnvelope.XMin = 2
    pEnvelope.YMax = 10
    pEnvelope.YMin = 2
    Dim pGeometry As IGeometry
    Set pGeometry = pEnvelope

    ' Set picture to have envelope geometry, this places it on pagelayout
    Dim pElement As IElement
    Set pElement = pPictureElement5
    pElement.Geometry = pGeometry

    ' Set name property (useful)
    Dim pElementProp3 As IElementProperties3
    Set pElementProp3 = pElement
    pElementProp3.Name = "My Picture"

    ' Add picture to Layout and refresh
    Dim pPageLayout As IPageLayout
    Set pPageLayout = pMxDoc.PageLayout
    Dim pGraphicsContainer As IGraphicsContainer
    Set pGraphicsContainer = pPageLayout
    pGraphicsContainer.AddElement pElement, 0
    pGraphicsContainer.UpdateElement pElement

End Sub
  • Thanks Hornbydd, I will try converting this to c#. Maybe one of the steps I was doing wrong (based on your code) is that I was assigning geometry of a point instead of polygon extent to the ipictureelement. Would that cause an issue? Also you mentioned image path coming from hard drive, I was referencing the image on on a shared drive on the network. Could that cause an issue too?
    – DaBears
    May 7, 2018 at 1:38
  • The point geometry may have caused an error, until I set the geometry of the element the AddElement method threw a generic error. I would have thought the location of the image should not be an issue.
    – Hornbydd
    May 7, 2018 at 10:47
  • This worked, thanks Hornbydd and everyone that posted
    – DaBears
    May 7, 2018 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.