+ Reply to Thread
Results 1 to 22 of 22

Show picture from webpage on userform

  1. #1
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Show picture from webpage on userform

    Hi everyone,

    I know how to display a photo saved on my hard disk on a vba user form, but I am asking if I can do the same thing if the photo is available on a webpage such as:

    http://www.therichest.org/celebnetwo...bill-gates.jpg

    I hope that I can find a smart way for that.

    Best Regards,
    Last edited by LoveCandle; 03-19-2012 at 12:47 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Show picture from webpage on userform

    Use URLDownloadToFile to download it to a local file, then:

    Image1.Picture = LoadPicture(localFileName)

    where Image1 is the image control on the user form.

  3. #3
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Show picture from webpage on userform

    I am familiar with the way you mentioned Chippy,

    But I want to get the picture from the internet direclty without downloading it to my local drive.

    Is that possible in VBA,

    Regards,

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Show picture from webpage on userform

    Yes, it is possible using the Microsoft Web browser (additional controls) on the userform. I don't know if it is present in Excel 2003 or not.

    Can you upload a dummy copy of your workbook so we can see where the URLs are in the workbook and what the userform you want will look like.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  5. #5
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Show picture from webpage on userform

    Yes My workbook is attached.

    By the way I am using MS Office Excel 2007.

    Regards,
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Show picture from webpage on userform

    Code for the web browser technique mentioned is:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Show picture from webpage on userform

    Thank you very much all,

    That is exactly what I am looking for since a logn time.

    But, Is there a way to hide the horizintal and vertical scroll bars?

    Regards,

  8. #8
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Show picture from webpage on userform

    Here is an example from a project I created for someone a while back. I have put URLs for three different sized excel related images (from very small, icon-sized) to large. You will see that using Ivan's code, the small ones are stretched and the large ones are shruken to fit the size of the web browser.

    Let me know if you need help implementing this in your workbook.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Show picture from webpage on userform

    Thank you very much abousetta for your cooperation,

    Your example is really very useful, but unfortunately it does not fit my need.

    My problem is that in the company I work for, there is a huge database for all employees data, and when you search for any employee, you will find his information beside his photo in one webpage. In other words, the employee’s photo is not the only content in the required webpage as well as the photo available on the following link:

    http://www.microsoft.com/presspass/exec/billg/

    My question is that: Is there any way to make VBA UserForm WebBrowser focus and preview the employees photo and a part of the webpage and ignore all other contents.

    I hope that my question and need is clear for you,

    Best Regards,

  10. #10
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Show picture from webpage on userform

    I see your problem and there probably is a simple solution, but I am not that familiar with HTML to help you. I can though give you some points that I noticed.

    1) In the HTML for the website, here is the section for linking the picture:
    HTML Code: 
    2) The URL for this file is http://www.microsoft.com/presspass/i.../billgates.png

    So you could make the assumption that if you can use XML or an interface between vba and IE to read the HTML then you would search the webpage for the picture you are looking for and create a URL that would be loaded into the MS Web Browser on your Userform.

    This needs someone with a lot more understanding and experience to assist with.

    Sorry I couldn't be of more help.

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

    Re: Show picture from webpage on userform

    You could extract the image url from the webpage and navigate to this within the webbrowser, can you post the HTML source of a page?

  12. #12
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Show picture from webpage on userform

    Thank you very very much abousetta for your great and useful help in this regard.

    Best Regards,

  13. #13
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Show picture from webpage on userform

    Quote Originally Posted by Kyle123 View Post
    You could extract the image url from the webpage and navigate to this within the webbrowser, can you post the HTML source of a page?
    I will post it ASAP.

    Regards,
    Last edited by LoveCandle; 03-16-2012 at 12:14 PM.

  14. #14
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Show picture from webpage on userform

    Finally I reached my goal after implementing the code posted by abousetta.

    Thank you for everyone participated in this subject.

    Best Regards,

  15. #15
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Show picture from webpage on userform

    Hi @LoveCandle,

    Could you post your final solution so others can learn from it?

    Thanks and good luck.

    abousetta

  16. #16
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Show picture from webpage on userform

    Yes sure,

    Here is my final code:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    05-30-2015
    Location
    SVK
    MS-Off Ver
    2016
    Posts
    38

    Re: Show picture from webpage on userform

    Hi, so how do you load picture into the "Image control", not a webbrowser and without making a temporary html document?

  18. #18
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Show picture from webpage on userform

    pulsar777 Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  19. #19
    Registered User
    Join Date
    05-30-2015
    Location
    SVK
    MS-Off Ver
    2016
    Posts
    38

    Re: Show picture from webpage on userform

    Quote Originally Posted by FDibbins View Post
    pulsar777 Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Hi FDibbins,
    sorry, I thought of repeating the original question without starting a new thread, while it seems the question has not been aswered fully. Thanks for a reminder, I'll try to be more careful next time.

  20. #20
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Show picture from webpage on userform

    Not a problem, thanks for understanding

  21. #21
    Registered User
    Join Date
    07-28-2017
    Location
    indonesia
    MS-Off Ver
    2017
    Posts
    1

    Re: Show picture from webpage on userform

    Hi @LoveCandle,

    Could you attached your final workbook file so others can learn from it?

    Thanks and good luck.

    Kafung777

  22. #22
    Registered User
    Join Date
    09-02-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    1

    Re: Show picture from webpage on userform

    Hi all,

    I used the code from the (abousetta's) attached document in this thread and I found it very useful to pull off some website imagery. It's very useful, but it seems to stop excel excel from being able to switch to any other active excel sheet. (I'm on Excel 2007). Can anyone help pinpoint why this happens?

    Many thanks,
    Italic

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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