0

This post shows the code I'm using to insert an image into the page layout. It works fine, but it's using a hard coded path. Adding picture to ArcMap PageLayout using ArcObjects in .NET?

Currently my code looks for the image in the user's ArcGIS folder, or if not there at a shared network folder, or else it doesn't insert it.

    strPath1 = Environ("USERPROFILE") + "\Documents\ArcGIS\logo.bmp"
    strPath2 = "Z:\networkfolder\logo.bmp"
    If Exists(strPath1) Then
        picElement5.ImportPictureFromFile(strPath1)
    ElseIf Exists(strpath2) Then
        picElement5.ImportPictureFromFile(strPath2)
    Else
        Dim Result As DialogResult
        Dim Buttons As MessageBoxButtons = MessageBoxButtons.YesNo
        Result = MessageBox.Show("image not found, not inserted", "title", Buttons)
        Exit Sub
    End If

What I would like to do is include the image in the Images folder of the AddIn. In the Config.esriaddinx file it allows images to be used from a subfolder, but picElement5.ImportPictureFromFile doesn't support relative paths.

Is there a different method to import an image into the page layout or a way to install them image into a standard folder that would work for all users. I need to distribute this addin to other users in the office.

I'm using ArcGIS 10.6, VB in Visual Studio 2017.

2

If you store the image in a folder and that is packaged as part of the AddIn then look at this Q&A it has some c# code to show you how to work out the folder location of where the AddIn is stored, it would then be a simple matter of building the path to the image and feeding it into picElement5.ImportPictureFromFile().

1
  • At first I wasn't sure where to put that code, but it worked at the top of my module. Now to test it with other users. I think it will work. – Mattropolis Jun 4 '20 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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