|
-
February 18th, 2010, 06:45 PM
#5
Re: How to know if InternetExplorer control has finished loading a multiframe web pag
Here's most of it. It also grabs images from the frames it finds (elsewhere)
Code:
' ==============================
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
Dim colDocuments As Collection
' ==============================
Private Sub Form_Load()
Dim objDoc1 As HTMLDocument
Dim objDoc2 As HTMLDocument
Dim i As Integer
Dim t As Integer
Set objDoc1 = New HTMLDocument
'Create document element from url
Set objDoc2 = objDoc1.createDocumentFromUrl("http://www.hamcams.com", vbNullString)
'Wait till document has loaded
Do While objDoc2.readyState <> "interactive"
DoEvents
Loop
GetFrames
'Loop through images
For t = 1 To colDocuments.Count
For i = 0 To objDoc2.images.length - 1
'download images and save them in app.path
URLDownloadToFile 0, objDoc2.images.Item(i).href, App.Path & "\Images\" & GetFile(objDoc2.images.Item(i).href), 0, 0
Next i
Next t
Set objDoc1 = Nothing
Set objDoc2 = Nothing
Beep
End Sub
Private Sub GetFrames()
'Purpose: searches all frames in the document(s) and adds them to colDocuments
On Error Resume Next
Dim i As Integer, j As Integer
j = 1
Set colDocuments = New Collection
colDocuments.Add WebBrowser1.document
Do While j < colDocuments.Count + 1
For i = 0 To colDocuments.Item(j).frames.length - 1
colDocuments.Add colDocuments.Item(j).frames.Item(i).document
Next i
j = j + 1
Loop
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|