?
Solved

getting an image from a web site

Posted on 2002-05-06
5
Medium Priority
?
132 Views
Last Modified: 2010-05-02
Hi,
 I know the url and name of an image that sits on a web site. I would like click a button on a VB form to automatically go to the URL and get the image to place on a directory on my machine. Of course, I can always do this manually by opening IE, navigating the the web site, right-clicking on the image, and "Save Target As". But how can I automate this in VB?

  1) Add a browser control to a Form?
  2) Tell the browser control to open a certain url
  3) ????? download the image ????? how??

The third step is where I need help.
Real working source code will get you the points.
TIA
DoughBoy
0
Comment
Question by:DoughBoy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 200 total points
ID: 6992073
You can use a quick and easy API function:

"HOWTO: Download a File Without Prompting (Q244757)"
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q244757
0
 

Author Comment

by:DoughBoy
ID: 6992105
good job!!
next time, I will learn to search the MS site myself.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6992159
reference microsoft internet transfer control and microsoft internet controls

put a webbrowser control on form and an inet control:

then do:
Private Sub Command1_Click()
'    On Error Resume Next
   
    WebBrowser1.Navigate "http://www.prototrack.com"
    While WebBrowser1.Busy
        DoEvents
    Wend
   
    Dim strImageSrc As String
    Dim bData() As Byte
   
    Screen.MousePointer = vbHourglass
    For i = 0 To WebBrowser1.Document.images.length
        strImageSrc = WebBrowser1.Document.images(i).src
   
        '' call your download routine here
        bData = Inet1.OpenURL(strImageSrc, icByteArray)
               
        '' get the file name to write to
        strSaveFile = Split(strImageSrc, "/")
       
        '' write the byte stream to disk
        MsgBox strSaveFile(UBound(strSaveFile))
        Open App.Path & "\" & strSaveFile(UBound(strSaveFile)) For Binary Access Write As #1
        Put #1, , bData()
        Close #1

    Next
    Screen.MousePointer = vbDefault
End Sub
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6992162
damn, azra always get's the webbrowser control questions :(

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6992172
Lots of experience with it   :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question