+ Reply to Thread
Results 1 to 6 of 6

insert picture the same size and location of existing picture

  1. #1
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2013
    Posts
    116

    insert picture the same size and location of existing picture

    Hi,

    I am trying to develop code that will help users create reports formatted however they one. One aspect of this that I want to implement is for the user to determine where they want certain pictures to appear on a worksheet and what size they want those pictures. What I am thinking is that the user could insert a placeholder picture anywhere on the worksheet, and then when my macro runs it would replace that picture with an existing picture.

    So, what I am looking for is a button that I can click on a worksheet that replaces a placeholder picture with an existing picture. I'm not too concerned how that existing picture is selected, but perhaps a dialog could pop up to select a picture.


    The most important part of this is that the new picture would have to be resized to the exact dimensions as the placeholder (even if it skews the aspect ratio), and placed in the exact location of the placeholder.

    One thought: the placeholder doesn't necessarily have to be a picture -- if it is easier to have it as shape or something else, it doesn't matter, just something so the user can define where and what size pictures will appear in their reports.

    Thanks!
    Last edited by mcdermott2; 03-13-2015 at 10:18 AM.

  2. #2
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,905

    Re: insert picture the same size and location of existing picture

    Take a look at this website:

    http://www.mcgimpsey.com/excel/lookuppics.html

    And if that code doesn't suffice, try this code:

    Please Login or Register  to view this content.
    The size of the image will be the same size that you set the initial image to.
    Spread the love, add to the Rep

    "None of us are as smart as all of us."

  3. #3
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2013
    Posts
    116

    Re: insert picture the same size and location of existing picture

    Thanks, mcmahobt!

    I am familiar with the website that you pasted, but that is not exactly what I am looking for. That does not help me resize and place apicture based on an existing image (or at least I don't think it does).

    Concerning your code -- I can't get this to work, so am not sure if it can accomplish the task. How do I call the new image? How does the code identify the existing pictures location and size? . Thanks for the input!

    In case it helps, let me be a little more clear about my intent: I have a "backend" excel document which houses the locations of pictures for different inspections (so imagine cell A1 = C:\user\mydocuments\pic1.jpg, and A2 = C:\user\mydocuments\pic2.jpg and so forth). When the user runs my macro, they will be creating hundred of reports based on a "report template" that they will create. That is why I need to define a picture to a certain location -- so the macro will know where exactly to paste pictures for subsequent reports (what I'm thinking is the macro will look for "picture1" or something and replace it with the picture from the backend).
    Last edited by mcdermott2; 03-13-2015 at 10:50 AM.

  4. #4
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,905

    Re: insert picture the same size and location of existing picture

    I'm not too VBA savy, but I was able (with the help of others on the forum) to alter the McGimpsey code to fit my needs for a previous project of mine. I have a similar situation for scheduling. I wanted an image to appear for multiple dates when data from another input changed.

    My code fundamentally works the same way McGimpsey's does, but with a few tweaks.

    1) The code works for more than one image.
    2) The code does not copy/replace every image every time. Just ones that Excel has recognized has either changed value or size/shape.

  5. #5
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,350

    Re: insert picture the same size and location of existing picture

    Hi mcdermott2,
    maybe something like this
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2013
    Posts
    116

    Re: insert picture the same size and location of existing picture

    That works like a charm, nilem. Thanks!

    So for my case, when my macro runs, it would simply need to paste the "new picture" into the worksheet, rename it as "Picture 3" and then this macro will function.

    I appreciate the help!

+ 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. Click on picture and run macro to replace existing picture with selected picture file
    By houseflipsheet in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2014, 12:02 AM
  2. [SOLVED] macro: insert picture based on workbook location, not picture root path.
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2012, 07:47 AM
  3. [SOLVED] How to insert picture and automatically size to cell?
    By ursa_nz in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 PM
  4. How to insert picture and automatically size to cell?
    By David McRitchie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 09:05 AM
  5. How to insert picture and automatically size to cell?
    By ursa_nz in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM

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