+ Reply to Thread
Results 1 to 17 of 17

Please Help! Trying to take an image URL and have the image show up in Excel

  1. #1
    Registered User
    Join Date
    07-01-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 13
    Posts
    24

    Please Help! Trying to take an image URL and have the image show up in Excel

    Hi I hope this hasn't been posted before, if it has I am sorry, I looked but couldn't find anything. Her is my problem.

    I have 2 columns, Column A has several peoples names:
    Column A
    Pranav Salunke
    Vincent Untz
    William Vera
    Artem Chernikov
    Dirk Mueller

    Column B has a link to their image:
    Column B
    https://media.licdn.com/mpr/mpr/shri...a3/2ab00ef.jpg
    https://media.licdn.com/mpr/mpr/shri...e7/10d7e2c.jpg
    https://media.licdn.com/mpr/mpr/shri...0a/350c8aa.jpg
    https://media.licdn.com/mpr/mpr/shri...2b/1ef2cbe.jpg
    https://media.licdn.com/mpr/mpr/shri...16/1eba1fa.jpg


    I would like Column C to show the actual image of the person from the URL in Column B
    Column C
    "image"
    "image"
    'image"
    "image"
    "image"

    ----------------
    First, I understand from looking it up and looking at youtube videos that I need to use VBA, but none of the videos that I see are using external
    url's it usually points to some place on their hard drive. Second, I haven't done VBA before, I really need a step by step on how to get in to it and what I need to create it and so on. Third, I would like to set this up as a template, so that when I copy and paste data it will auto populate, or if I have to run the Macro again that's fine, I would have at most 1500 names and their respective image url's.

    Thank you so much in advance if anyone can help me.
    Last edited by jkfoxworth; 07-20-2015 at 04:29 PM.

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    If you have a valid url, I could test it. The problem comes in resizing the image shape/picture. It would be best to at least download the image file and then use WIA to get dimensions so you can size your cells and shapes accordingly. 3rd party software can be shelled to get picture file dimensions and set size dimensions.

    To get you started:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-01-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 13
    Posts
    24

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Hi Kenneth, the URLs that I provided are valid URLs from LinkedIn, I would imagine that they would be all the same size. Thanks for responding!!!

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Valid for you maybe, not for me. Give it a shot and see if it works for you. You will have to play with the dimensions to get them set as you like.

  5. #5
    Registered User
    Join Date
    07-01-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 13
    Posts
    24

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Hi Kenneth I am sorry the URL isn't correct, this is the correct URL https://media.licdn.com/mpr/mpr/shri...a3/2ab00ef.jpg

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    With
    Col_B containing URL text

    Please Login or Register  to view this content.
    and this VBA code loops through the current selection of cells and runs the above macro to retrieve pictures and place them to the right of the URL cells
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  7. #7
    Registered User
    Join Date
    07-01-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 13
    Posts
    24

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Hi Kenneth, so I am getting it to work - thank you so much, now how could I adjust the code to get it to repeat for a range of rows and columns, eg Column C, the code you gave me was for a specific URL, I would need it to be able to see the URL in Column C.
    https://media.licdn.com/mpr/mpr/shri...a3/2ab00ef.jpg
    https://media.licdn.com/mpr/mpr/shri...e7/10d7e2c.jpg
    https://media.licdn.com/mpr/mpr/shri...0a/350c8aa.jpg
    https://media.licdn.com/mpr/mpr/shri...2b/1ef2cbe.jpg
    https://media.licdn.com/mpr/mpr/shri...16/1eba1fa.jpg

    How could I get pictures for each url (URLs are correct now )
    Last edited by jkfoxworth; 07-20-2015 at 04:34 PM.

  8. #8
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Before I show you, in the Visual Basic Editor (VBE), set the View to show the Immediate window. Select a picture that was inserted and then size width and height as you like manually. With the picture selected, run this code. Note the dimensions shown in the Immediate Window as adjust range and picture heights and widths accordingly.

    Please Login or Register  to view this content.

  9. #9
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Adjust as needed.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-01-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 13
    Posts
    24

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Hi Kenneth, again thank you so much for everything.
    Not sure if it did anything and not sure if I did it correctly, you mention that I show the immediate window, is that just the excel spreadsheet that has my information on it like URL? I do that, I formatted the picture size and kept the window selected. I then opened up VBE and ran the code and nothing happened. Prior to this I adjusted the .ShapeRange.Height to 50# and kept .ShapeRange.Width to 50# and this brought my picture to a good height and width. Could this be the cause why the most recent code isn't working? Thanks

  11. #11
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Your url paths must be in B2 and down on the activesheet for my code to work right when your Run it. Keeping the image square in dimensions should work fine as that is the aspect ratio of those images. You will need to reset the row heights and column height for the rows as well. Of course you only need to reset the column width once but it works so fast doing both in my routine, it should not be a performance issue.

    The Immediate window can be a handy debugging tool. You could use MsgBox rather than Debug.Print to see results at run time. Here is one link that shows more about that window. It is a technique worth learning. http://www.excelcampus.com/vba/vba-i...-window-excel/

    Be sure that you did paste my code into a Module. http://www.contextures.com/xlvba01.html
    Last edited by Kenneth Hobson; 07-20-2015 at 05:20 PM.

  12. #12
    Registered User
    Join Date
    07-01-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 13
    Posts
    24

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Picture.png
    Hi Kenneth,

    Not sure if I am understanding where to put the code, this is what I have so far and this is giving me the desired result (I tried to upload a picture), also the picture size is perfect I am using a .ShapeRange.Height of 40# and a .ShapeRange.Width of 40# (this Aspect should always work because the picture sizes while different should always stay the same). Now I want to be able to get the image to appear for every URL. I can manually run the code for each URL but this would take forever to do working with a few hundred or more people.
    Here is what I have so Far


    Sub Test_InserPicPath()
    InsertPicPath Range("B1"), "https://media.licdn.com/mpr/mpr/shrinknp_400_400/p/5/005/079/2a3/2ab00ef.jpg"
    End Sub

    Sub InsertPicPath(r As Range, fPath As String)
    Dim pic As Object

    Set pic = ActiveSheet.Pictures.Insert(fPath)
    With pic
    .Top = r.Top
    .Left = r.Left
    .ShapeRange.LockAspectRatio = msoFalse
    .ShapeRange.Height = 40#
    .ShapeRange.Width = 40#
    .ShapeRange.Rotation = 0#
    End With
    End Sub
    Attached Images Attached Images

  13. #13
    Registered User
    Join Date
    07-01-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 13
    Posts
    24

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Sorry I posted the picture twice by accident, the code should actually be the following, I left the B2 in there because I manually did the next person's URL. Not sure if it makes a difference


    Sub Test_InserPicPath()
    InsertPicPath Range("B1"), "https://media.licdn.com/mpr/mpr/shrinknp_400_400/p/5/005/079/2a3/2ab00ef.jpg"
    End Sub

    Sub InsertPicPath(r As Range, fPath As String)
    Dim pic As Object

    Set pic = ActiveSheet.Pictures.Insert(fPath)
    With pic
    .Top = r.Top
    .Left = r.Left
    .ShapeRange.LockAspectRatio = msoFalse
    .ShapeRange.Height = 40#
    .ShapeRange.Width = 40#
    .ShapeRange.Rotation = 0#
    End With
    End Sub

  14. #14
    Registered User
    Join Date
    07-01-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 13
    Posts
    24

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Hi Kenneth when I run the code I get the following Error, I also ran with and without the 'Not needed if lockapsectration=msotrue (wasn't sure if that was something you wanted me to edit or not) and both returned the 400 error Picture2.png
    Last edited by jkfoxworth; 07-20-2015 at 05:29 PM.

  15. #15
    Registered User
    Join Date
    07-01-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 13
    Posts
    24

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Hi Ron, can I just copy and paste your data in to my VBA of my spreadsheet, for some reason it isn't allowing me to run it? Thanks

  16. #16
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    You should create a new module for the workbook and put the code in that new module....not in a sheet module.
    • ALT+F11...to open the Visual Basic Editor
    • Right-click on your workbook's name in the VBA - Projects window
    ...Select: Insert Module

    Does that help?

  17. #17
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Please Help! Trying to take an image URL and have the image show up in Excel

    Follow Ron's short instructions for inserting a Module from the VBE or see the link that I posted.

    Of course if you attach a file, we can better test it for you. You may have a blank entry that needs to be handled. Click the Go Advanced button in lower right of a reply and click the paperclip icon on the toolbar to browse to your file to attach. That is often the best way to get on target 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. [SOLVED] How to apply Image borders to an image that my excel vba userform pastes in a word doc?
    By CaptainCool in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-11-2014, 05:40 PM
  2. Excel 2010 "vlookup pictures vba" links image instead of saving it as an image
    By neverdom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-28-2013, 04:17 AM
  3. VBA: Put text from excel to jpeg image by matching image name.
    By sroysroy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 01:47 AM
  4. [SOLVED] on load, show image in excel userform web components
    By Megatronixs in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-28-2013, 03:16 AM
  5. Image show in Excel
    By SathishKumar in forum Excel General
    Replies: 1
    Last Post: 09-17-2012, 04:03 AM
  6. excel 2010 VBA InsertPicInRange only makes shortcut to image instead of copy of image
    By ArjanSpit in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2012, 02:57 PM
  7. Show image with text when a excel file opens.
    By johnyc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2008, 05:03 AM

Tags for this Thread

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