Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List

   
 
MS Access

Download Images from Web

Use this to get all images from a Webpage and download them to a local folder

In this tutorial I will explain how to download all images on a given webpage to a local folder.

This was originally show as a blog post.

YouTube Link: TIP: Download Images from a Website to a Folder

Create a Form

Add some controls

  • WebBrowser0 - ActiveX Control
  • URL - TextBox
  • lstImages - List Box
  • cmdNavigate - Command Button
  • cmdDownload - Command Button

Share the code here:

	Private Declare Function URLDownloadToFile Lib "urlmon" 
		Alias "URLDownloadToFileA" 
		(ByVal pCaller As Long, 
		ByVal szURL As String, 
		ByVal szFileName As String, 
		ByVal dwReserved As Long, 
		ByVal lpfnCB As Long) As Long
	
	Private Sub cmdDownload_Click()
		
		Dim i As Integer
		For i = 0 To lstImages.ListCount - 1
			Download (lstImages.ItemData(i))
		Next i
		
	End Sub
	
	Sub Download(file As String)

		Dim done, pathOfdb, fn, saveTo
		pathOfdb = CurrentProject.Path & "\"
		fn = filename(file)
		saveTo = pathOfdb & fn
		
		MsgBox file
		MsgBox saveTo
		
		done = URLDownloadToFile(0, file, saveTo, 0, 0)
		
		If done = 0 Then
			MsgBox "File has been downloaded!"
		Else
			MsgBox "File not found!"
		End If
		
	End Sub
	
	Private Sub cmdNavigate_Click()
		
		EventRunning = True
		WebBrowser0.Navigate URL
		While EventRunning
			DoEvents
		Wend
		
	End Sub
	
	Private Sub WebBrowser0_DownloadBegin()
		IsNavigating = True
	End Sub
	
	Private Sub WebBrowser0_DownloadComplete()
		
		IsNavigating = False
		Dim Obj
		
		For Each Obj In WebBrowser0.Document.All
			If Obj.TagName = "img" Then
				ImageHTML = ImageHTML & " " & Obj.OuterHTML
				ImageSrc = ImageSrc & " " & Obj.getAttribute("src")
				lstImages.AddItem Obj.getAttribute("src")
			End If
		Next
		
	End Sub
	
	Function filename(src As String)

		Dim val, fn
		'http://www.599cd.com/images/pc-logobar.gif
		val = InStr(StrReverse(src), "/")
		fn = Right(src, val - 1)
		
		filename = fn
		
	End Function
	

I'll look for the original db...


 

Alex Hedley (Avatar) By: Alex Hedley


Click here to sign up for more FREE tips

 

 

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/28/2024 5:39:45 AM. PLT: 0s