CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2012
    Posts
    3

    Add image to worksheet from My.Resources with Excel Add-in

    I am working on my first Excel add-in ever, and my first VB app in 10 years. My how things have changed.

    I have an image in My.Resources and would like to place it on the ActiveSheet. I realize I could do the following:

    InsertPicture("C:\image.png", oXL.Range("A20"), True, True)

    But the image I have does not exist on the file system, it only exists as a resource embedded in the app. I can't figure out a way to push this image, or even an empty image that could have its picture property updated to this image, to the sheet. Any ideas?

    If this is impossible, another option would be to use the InsertPicture statement, if I can figure out how to package the image in with the install. So, any help with this would also be appreciated.

    Thanks,

    Sean

    P.S. I realize there are probably only two other people in the world writing Excel add-ins in VB, but I thought I would try.

  2. #2
    Join Date
    Jul 2012
    Posts
    3

    Re: Add image to worksheet from My.Resources with Excel Add-in

    I forgot to mention, I am using Excel 2007 & Excel 2010, and VS 2010.

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Add image to worksheet from My.Resources with Excel Add-in

    Copy the RESOURCE to a BYTE file, or even PNG format (if you know it). Otherwise you'll have to convert it to a PICTURE and then use that instead.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Jul 2012
    Posts
    3

    Re: Add image to worksheet from My.Resources with Excel Add-in

    I have a .png file, but I wanted to embed it in the My.Resources so I didn't have to deal with the external file. If the external file is the best solution, then how do I include it in the install package, and how do I know the folder into which it gets installed?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured