+ Reply to Thread
Results 1 to 10 of 10

Display image from URL in a UserForm without downloading into local drive

  1. #1
    Registered User
    Join Date
    06-24-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    19

    Display image from URL in a UserForm without downloading into local drive

    Hello,

    I have a userform with an image1 object. I'd like to insert an image into that image object directly from a url address (e.g. http://upload.wikimedia.org/wikipedi...013_Google.png). I'd like to do this without the need to download the image file into my default C: drive if possible.

    I've researched this on the web and have come across a few threads, but none seem to work as described by the OP as listed below:


    http://www.experts-exchange.com/Soft....html#view-all

    http://www.excelforum.com/excel-prog...ml#post3942354

    http://www.excelforum.com/excel-prog...-userform.html


    Thanks,

    Noel

  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: Display image from URL in a UserForm without downloading into local drive

    Obviously, you can not use the method posted in the last link for an Image object. If you are going to use that method, use the WebBrowser control as they did.

    I did a userform with their image and yours. In the VBE, be sure to set a reference in Tools > References to the Microsoft Internet Controls, if it shows missing in the attached file. I also did some tweaks to the code. I wanted the control to resize to the image size. Of course that is the advantage of downloading images, you can easily find the size and makes this kind of thing easier. Actually, for the browser control method, it does download the images. In any case, have fun.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    06-24-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Display image from URL in a UserForm without downloading into local drive

    Hi Kenneth,

    Thank you for your quick response. I appreciate it.

    Your example file helped me understand the code and I've successfully modified it to lookup the url in another worksheet since the image url changes depending on other criteria. Is it possible to not show the border around the object? I can't find any settings for that in the object properties.

    All the best,

    Noel

    Edit: Sorry, I should have searched deeper. I found the code. Here it is:

    Please Login or Register  to view this content.
    Last edited by noelglez; 12-31-2014 at 03:26 PM.

  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: Display image from URL in a UserForm without downloading into local drive

    Good deal.

    Not sure if it would help or not but if one looks at the html code for the Bill Gates, there is a tag for the img style="-webkit-user-select: none".

    cheers

  5. #5
    Registered User
    Join Date
    06-24-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Display image from URL in a UserForm without downloading into local drive

    Quote Originally Posted by Kenneth Hobson View Post
    Obviously, you can not use the method posted in the last link for an Image object. If you are going to use that method, use the WebBrowser control as they did.

    I did a userform with their image and yours. In the VBE, be sure to set a reference in Tools > References to the Microsoft Internet Controls, if it shows missing in the attached file. I also did some tweaks to the code. I wanted the control to resize to the image size. Of course that is the advantage of downloading images, you can easily find the size and makes this kind of thing easier. Actually, for the browser control method, it does download the images. In any case, have fun.
    Hello Kenneth, thank you once again for your help with this code. I've come across an issue that I hope you can help me figure out. The issue is that URL images I'm importing to the useform are company logos, which come in all shapes and sizes. I'd like to keep each logo's aspect ratio, but not their original size. In other words, I'd like all logos appear the center of an image object without any stretching and staying within the boundaries of the image object. Following are three examples, the fist two are "rectangular images" whereas the third is a "square image". Using the current code, the 3rd url image is stretched.

    1. http://www.grainesdeboss.fr/photos/j...grosquadri.jpg
    2. http://www.tabithasingapore.com/medi...1b_400x170.jpg
    3. http://www.sefco-export.com/neer1.gif

    Is there a way to accomplish this?

    Thanks,

    Noel

  6. #6
    Registered User
    Join Date
    06-24-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Display image from URL in a UserForm without downloading into local drive

    Hi Kenneth,
    I'm bumping this hoping you or someone else can help me.
    Thanks,
    Noel

  7. #7
    Registered User
    Join Date
    06-24-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Display image from URL in a UserForm without downloading into local drive

    I've attached a sample file using Kenneth's code to demonstrate what I mean.

    The 4th URL image in userform1 is the same as the 3rd URL image, but I had to manually enter this image's proper width and height to keep it's aspect ratio (almost square). As you can see the 3rd image looks stretched because it is using the WebBrowser3 object's width and height.

    Is there a way to keep the URL image's original aspect ratio and "auto fit" into the WebBrower's object without stretching the image or having to predefine a width and height.

    I need this image "auto fit" because I am referring to hundreds of company logos that have different widths, heights and aspect ratios, and any one of them may appear depending on other search criteria.

    Thank you in advance for your help.

    Noel

    LoadPicFromURL.xlsm

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Display image from URL in a UserForm without downloading into local drive

    Change to this:
    Attached Files Attached Files
    Last edited by Kyle123; 01-16-2015 at 01:49 PM. Reason: Better code

  9. #9
    Registered User
    Join Date
    06-24-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Display image from URL in a UserForm without downloading into local drive

    Quote Originally Posted by Kyle123 View Post
    Change to this:
    Thank you, Kyle123! That did the trick.

    Now, is there a way to have the image centered vertically in the WebBrowser object? It seems the image is centered horizontally, but not vertically.

    Also, I noticed the following code no longer works to remove the WebBrowser object border:

    Please Login or Register  to view this content.
    How can I make this work within the change you provided?

    Regards,

    Noel
    Last edited by noelglez; 01-16-2015 at 03:22 PM.

  10. #10
    Registered User
    Join Date
    06-24-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Display image from URL in a UserForm without downloading into local drive

    I'm bumping this thread hoping someone can help me.
    Thanks,
    Noel

+ 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] Display image from URL in a UserForm
    By jaskamakkara in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-30-2014, 05:42 PM
  2. VBA - share name of a local drive
    By katto01 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-16-2013, 07:30 AM
  3. Userform Combobox to display image name from file
    By manda_w in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-29-2013, 03:21 AM
  4. how to display an image in userform
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2012, 06:53 AM
  5. Windows XP : Local Drive Mapping
    By robzrob in forum Microsoft Windows Help
    Replies: 1
    Last Post: 02-13-2010, 07:07 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