Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

getting an image from a web site

Posted on 2002-05-06
5
Medium Priority
?
133 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

596 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