Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Hyperlink downloads

Dear Support Members,

I have a webpage that contains several hyperlinks. I wish to write some
Excel VBA to download/copy the destination of all the hyperlinks. For
example, if the webpage contains links to four .jpg images, I would like the
Excel VBA to copy those four images to c:\temp

Thanks in advance,

Christmas May
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Hyperlink downloads

Chris

I did try working on this but not yet arrived at a situation where I
can store all the targets in a folder. But i have a solution where you
can get url of all the hyperlink targets to the destination. I hope
this helps and if i do get a solution wehre you can store in a folder,
i will let you know... Copy the following code and paste in a new code
module.

Option Explicit
Dim nwSht As Worksheet

Sub hyperlinkInformation()
Dim IE As Object
Dim doc, element
Dim shtName As String
shtName = InputBox("Give a name to the new sheet")
Call Get_New_SHeet(shtName)

Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate GetUrl
IE.Visible = True
Do Until IE.busy = False
DoEvents
Loop
Set doc = IE.Document
Dim i As Integer
i = 2
For Each element In doc.all.tags("A")
nwSht.Cells(i, 1) = element.innertext 'prints the text of the
hyperlink
nwSht.Cells(i, 2) = element 'prints the hyperlink itself
'press ctrl-g to see debug window
i = i + 1
Next element

MsgBox "Done"
End Sub

Private Sub Get_New_SHeet(ByVal shtName As String)
Set nwSht = ActiveWorkbook.Sheets.Add
nwSht.Name = shtName
nwSht.Activate
With nwSht
.Cells(1, 1) = "Link text"
.Cells(1, 2) = "Link URL"
.Columns(1).ColumnWidth = 35
.Columns(2).ColumnWidth = 50
End With
nwSht.Activate
End Sub
Private Function GetUrl()
GetUrl = InputBox("Enter the url for the get the hyperlinks " & _
"on that page/doc", "", _
"http://socko.wordpress.com/site-contents/")

If UCase(Left(GetUrl, 7)) < "HTTP://" Then
MsgBox "Please enter the url starting with http:// and try again"
Exit Function
GetUrl = ""
End If
End Function

Go to the following url if to download the example file.
http://www.sockofiles.350.com/get=_linktargets=_url.xls

I hope this helps.

- Selva

Fore more info on vba info, visit http://socko.wordpress.com
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Template downloads Bruce Burlingame New Users to Excel 1 November 5th 08 12:01 AM
Schedule downloads Andyjim Excel Programming 1 January 23rd 08 08:24 PM
Schedule Downloads Andyjim Excel Programming 0 January 23rd 08 12:26 AM
File Downloads in VBA Sysygy Excel Discussion (Misc queries) 1 April 8th 05 06:45 PM


All times are GMT +1. The time now is 02:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"