+ Reply to Thread
Results 1 to 11 of 11

Image Embed into a Shape from a URL?

  1. #1
    Forum Contributor
    Join Date
    02-27-2007
    Posts
    156

    Image Embed into a Shape from a URL?

    I am needing to take the URL from Sheet 1 which contains an Image and put that into an area on Sheet2. I seem to be gathering that this will likely require a shape to be in the place you want the image and that the image is loaded into the shape? Ideally I would like to ultimately embed the image so that if offline the image can still be used on the worksheet but if online it grabs whatever is in the URL.

    I've clipped the pieces of my workbook that are included here.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    02-27-2007
    Posts
    156

    Re: Image Embed into a Shape from a URL?

    The image should be printable... I think that is why it is required to be in a shape?

  3. #3
    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: Image Embed into a Shape from a URL?

    Hello bmasella,

    The attached workbook will insert the web picture into the rectangle shape when the URL is changed. If the there is a problem, you will be altered and the macro will exit without changing the picture in the rectangle.

    Module1 - Macros to retrieve the Web Picture
    Please Login or Register  to view this content.
    Sheet1 - Worksheet Change Event
    '
    Please Login or Register  to view this content.
    Attached Files Attached Files
    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!)

  4. #4
    Forum Contributor
    Join Date
    02-27-2007
    Posts
    156

    Re: Image Embed into a Shape from a URL?

    Leith great help as always.

    When I change the URL on your sample workbook I get a compile error... Duplicate declaration in current scope.

    Is there a way to keep the aspect ratio when inserting into the shape so it doesn't "stretch" to fit?

    What is the Local File I see reference. Does it need to exist?

    Where do I find the reference to the cell that has the image URL for it to load into the shape? (If I wanted to repeat this for a different cell into a different shape)

    Does there have to be a Hyperlink to that URL or is plain text enough?

    Thanks.

  5. #5
    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: Image Embed into a Shape from a URL?

    Hello bmasella,

    Q-1 When I change the URL on your sample workbook I get a compile error... Duplicate declaration in current scope.

    A-1 Oops, I that I had removed that offending line of code. In Module1, delete the line "Dim URL As String" in the Macro GetImage.


    Q-2 Is there a way to keep the aspect ration when inserting into the shape so it doesn't "stretch" to fit?

    A-2 The picture size can be manipulated by code. Before I can say more, I need to know more about how you want to display the image.


    Q-3 What is the Local File?

    A-3 LocalFile is defined in the macro GetImage. Currently, the path is set to "C:\Test\WebImage.jpg". You can change this to where you want to save the image.


    Q-4 Where do I find the reference to the cell that has the image URL for it to load into the shape?

    A-4 This is passed into the macro GetImage from the Worksheet_Change event macro on Sheet1.


    Q-5 Does there have to be a Hyperlink to that URL or is plain text enough?

    A-5 No, plain text can used. I wrote the macro based on what you made available in the workbook. A hyperlink will always be a fully qualified web path which the macro requires. Plain text would require writing code to duplicate this process.

  6. #6
    Forum Contributor
    Join Date
    02-27-2007
    Posts
    156

    Re: Image Embed into a Shape from a URL?

    Thanks for the prompt response...

    Q1 - I will fix this and play around with it.

    Q2 - The image regardless of the source size needs to fit into the size of the shape on the worksheet.

    Q3 - The local file will then allow me to run in offline mode?

    Q4 - So if I wanted to have two of them... defined and I want one of them to appear on sheet 2 and the other one to appear on sheet3 I would need to adjust the module code to reflect this.

    Q5 - I can use a hyperlink. I just needed to know if that was a rule or not.

  7. #7
    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: Image Embed into a Shape from a URL?

    Hello bmasella,

    A-2 The "Fill" property of the Shape will always fit the image to the shape. This may cause the image to stretch in order to completely fill the shape's interior. Forcing the aspect ratio may result in the image being clipped.

    A-3 The image will remain once the workbook is saved. It will only change if you change the URL.

    A-4 Are you referring to URLs or Shapes?

  8. #8
    Forum Contributor
    Join Date
    02-27-2007
    Posts
    156

    Re: Image Embed into a Shape from a URL?

    Q-2. Hmm... I'm thinking that clipping wouldn't be so bad.

    Q-3. Not sure I understand this. So the worksheet with the shape where the image is going to be displayed looks for the local file and loads from there? Couldn't I just put the image into the local path defined and not have to do the web download thing at all? IE the images live in the same folder as the workbook and I just define on sheet 1 which image to use and then the VBA places it into the appropriate shape? (change of scope I know but it would eliminate the Internet thing altogether... another hmmm)

    Q -4. The URLs are on sheet 1, the shapes would be on other worksheets (the potential use is images at the top of each worksheet )

    Q-5. Still not sure I see how Sheet1 E:7 is getting passed into the routine. (I'm first to admit I don't know a lot about VBA)

  9. #9
    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: Image Embed into a Shape from a URL?

    Hello bmasella,

    A-2 I can change the macro to clip the image.

    A-3 The LocalFile is where the web image will saved on the hard disk. The macro loads this file into the Rectangle Shape.

    A-4 To load URLs into other shapes can be done. The macro will need some way of knowing where to place the URLs. How many shapes do plan on having? How many per sheet?

    a-5 The Worksheet_Change event for Sheet1 examines the "Target" (cell or cells that are selected). The Target must be a single cell and contain a hyperlink. If these conditions are met then the address of the Hyperlink is passed into the macro "GetImage" as the argument URL.

  10. #10
    Forum Contributor
    Join Date
    02-27-2007
    Posts
    156

    Re: Image Embed into a Shape from a URL?

    Q-2 - In looking at my images...clipping is probably not a good idea.. It could lead to important pieces being dropped

    Q-3 - I tried to find this on my PC... couldn't. I assume it must need to be built. What if instead of using the web at all I just forced the files to live in the same folder as the workbook. I could put the file name instead of a full qualified URL into the field on the worksheet. This might just be the simpler solution overall.

    Q-4 - Perhaps passing into the function the source cell and the resulting rectangle ?

    Q-5 - So it is related to the field that the cursor is currently sitting in?

  11. #11
    Forum Contributor
    Join Date
    02-27-2007
    Posts
    156

    Re: Image Embed into a Shape from a URL?

    I just used this instead... Looks for a filename in the current folder and places it inside of a rectangle on a specific worksheet.

    Please Login or Register  to view this content.
    Last edited by bmasella; 07-28-2014 at 03:21 PM.

+ 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] Embed image to button using Image control
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2014, 05:37 PM
  2. [SOLVED] Use a button to control a macro that inserts an image into a shape or resets the shape
    By nwb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2013, 04:41 PM
  3. Embed Image JPG and Type Over it.
    By WileECoyote in forum Excel General
    Replies: 1
    Last Post: 04-06-2011, 07:52 AM
  4. Embed image in cell
    By sschroeder in forum Excel General
    Replies: 11
    Last Post: 12-16-2009, 03:56 PM
  5. Embed image in cell
    By AceX in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2008, 02:33 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