Solved

getting an image from a web site

Posted on 2002-05-06
5
125 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
  • 2
  • 2
5 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now