+ Reply to Thread
Results 1 to 6 of 6

How do you get the 'name' of an image inserted into a cell?

  1. #1
    Registered User
    Join Date
    01-13-2020
    Location
    usa
    MS-Off Ver
    office 365
    Posts
    15

    How do you get the 'name' of an image inserted into a cell?

    I'm trying to work with images that have been '.Pictures.Insert' ed into a cell. The examples I see use the image name to select it. This name seems to magically be assigned. In a macro experiment, the image was selected as

    Please Login or Register  to view this content.
    Where did "Picture 2" come from and, given I have the cell in which it resides, how to I grab it?

    Thank you.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How do you get the 'name' of an image inserted into a cell?

    Hello fatkatie,

    Okay, a short lesson on system object collections and yes there will be a test afterwards. Excel organizes objects using Collections, which are also objects. The Collection uses "key" and "item" pairs. The key can be a string name like "Picture 2" or and numeric index like 1. The Collection will retrieve the "item" associated with key or throw an error. Each Item in the collection can just about anything: an array, number, string, date, or an object.

    Each worksheet has a collection called "Pictures" that keeps track of Pictures belonging to the worksheet. When a Picture is added, the Collection creates a default name based on the object and a counter index value. This where the "Picture 2" comes from. You can of course change this name if you like. Either using the Name Box dropdown or through code.

    Please Login or Register  to view this content.
    Now that you assigned it to an Object variable, you can do what you like with it.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-13-2020
    Location
    usa
    MS-Off Ver
    office 365
    Posts
    15

    Re: How do you get the 'name' of an image inserted into a cell?

    Thank you. Good 101.

    Hoping to find its methods, I went into the excel object browser to find the Picture object used in the experiment macro:

    Please Login or Register  to view this content.
    I couldn't find it. So the problem for me is naming the image at insert time. I know the cell address, but the name is auto-generated. If I can't name it, or access the image indirectly via the cell address, I don't know how grab it.

    How do I do these things?

    Thanks again for the help.
    excel 365, w10

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow


    A beginner way : just compare the cell address with each picture cell address …

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: How do you get the 'name' of an image inserted into a cell?

    To continue on Marc L 's suggestion here a piece of code which deletes the picture recorded in the range WkRg
    You may use it the rename it or just to know what it is .

    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  6. #6
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: How do you get the 'name' of an image inserted into a cell?

    Quote Originally Posted by fatkatie View Post
    I couldn't find it. So the problem for me is naming the image at insert time
    Go through the code step by step with 'F8':
    Please Login or Register  to view this content.

+ 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. Inserting Image Hyperlinks to an Inserted Image
    By Chris Rod in forum Excel General
    Replies: 1
    Last Post: 05-14-2019, 03:41 AM
  2. VBA to cut image file path from word bookmark and replace with inserted image
    By JayRay1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2018, 07:31 PM
  3. VBA to cut image file path from word bookmark and replace with inserted image
    By JayRay1 in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2018, 12:02 AM
  4. [SOLVED] button erase dont erase an image inserted on an image control
    By Nuno Neves in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2014, 08:04 AM
  5. [SOLVED] How do I resize an inserted image in a cell?
    By tigerbenn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2012, 10:55 AM
  6. Remove Text From Cell When Image Is Inserted
    By swordswinger710 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2008, 01:48 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