+ Reply to Thread
Results 1 to 8 of 8

Insert userform image into a worksheet

  1. #1
    Forum Contributor Axmed.cm's Avatar
    Join Date
    02-05-2015
    Location
    Somalia
    MS-Off Ver
    2013
    Posts
    231

    Insert userform image into a worksheet

    Dear All,

    By clicking CommandButton1, Could any one help me insert an image in Userform1 in some where in the worksheet?

    Thanks in advance
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Axmed.cm; 12-06-2019 at 10:41 AM.
    GUURE

  2. #2
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    21,275

    Re: Insert userform image into a worksheet

    Add this code to your UserForm code to handle the button click. This code will create a temporary file based on the picture, insert it to the sheet, then delete the temporary file.

    Please Login or Register  to view this content.
    Adapted from a solution by Tim Williams
    Jeff
    | | |?| |?| |?| |?| | |:| | |?| |?|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor Axmed.cm's Avatar
    Join Date
    02-05-2015
    Location
    Somalia
    MS-Off Ver
    2013
    Posts
    231

    Re: Insert userform image into a worksheet

    Dear 6StringJazzer,

    Thank you for your help. this is exactly what i wanted. can I resize the picture and put it in specific cell, line cell D3:G6?
    Thanks again
    Ahmed

  4. #4
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    21,275

    Re: Insert userform image into a worksheet

    To put it in a specific cell, use code to Select that cell before the insert.

    "put it in specific cell, line cell D3:G6" That is 12 cells, I'm not sure what you are trying to do there.

    You can adjust the display size by adjusting the Shape attributes Height and Width after the insert. After the insert it can be referenced as Sheet1.Shapes(Sheet1.Shapes.Count)

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor Axmed.cm's Avatar
    Join Date
    02-05-2015
    Location
    Somalia
    MS-Off Ver
    2013
    Posts
    231

    Re: Insert userform image into a worksheet

    Thanks dear, its working...

  6. #6
    Registered User
    Join Date
    02-17-2020
    Location
    Germany
    MS-Off Ver
    2019
    Posts
    28

    Re: Insert userform image into a worksheet

    Quote Originally Posted by 6StringJazzer View Post
    To put it in a specific cell, use code to Select that cell before the insert.

    "put it in specific cell, line cell D3:G6" That is 12 cells, I'm not sure what you are trying to do there.

    You can adjust the display size by adjusting the Shape attributes Height and Width after the insert. After the insert it can be referenced as Sheet1.Shapes(Sheet1.Shapes.Count)

    Please Login or Register  to view this content.
    Hi, this piece of code has helped me a lot and works perfectly. I'm struggling with a follow-up problem though: If I save and restart Excel after inserting a shape this way, there's an error message that informs me that "The linked image cannot be displayed. The file may have been moved, renamed, or deleted. Verify that the link points to the correct file and location." The reason is probably that the temp file does not exist anymore, I guess? Is there a way to avoid this while still deleting the temp file at the end of the process?

  7. #7
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Türkiye
    MS-Off Ver
    2010 - 64 Bit on Win7
    Posts
    953

    Re: Insert userform image into a worksheet

    @Menohavename;

    Try this 6StringJazzer's revised code, where the picture is saved on cells D3:G6 exactly also.

    Please Login or Register  to view this content.

  8. #8
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    21,275

    Re: Insert userform image into a worksheet

    Quote Originally Posted by Menohavename View Post
    Hi, this piece of code has helped me a lot and works perfectly. I'm struggling with a follow-up problem though
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Insert PNG image into userform
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-10-2021, 03:56 AM
  2. Use a Userform button to insert image in worksheet
    By barrymac20 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-24-2019, 06:24 AM
  3. [SOLVED] Insert an image at a specific location on a worksheet
    By ozhunter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2015, 08:35 AM
  4. [SOLVED] VBA to transfer image FROM userform image control TO a worksheet cell
    By Zoediak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2014, 02:51 PM
  5. [SOLVED] Insert image on userform - .ico
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2014, 06:28 PM
  6. Replies: 1
    Last Post: 09-05-2012, 04:11 PM
  7. insert image - lookup in different worksheet
    By fredpox in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2010, 05:28 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1