sjeffress
asked on
Automation of IE6
Hi,
I would like some help with automating IE6.
In particular I wish to
1 - load a web page
2 - search the contents of the page to see if there are any pictures
3 - for pictures, determine the picture type, physical dimensions, size and any link that it may contain
4 - save the picture to the hard drive
Can someone please help
Thanks,
Steve
I would like some help with automating IE6.
In particular I wish to
1 - load a web page
2 - search the contents of the page to see if there are any pictures
3 - for pictures, determine the picture type, physical dimensions, size and any link that it may contain
4 - save the picture to the hard drive
Can someone please help
Thanks,
Steve
The below is in VB but can be adapted to VBA. It doesn't include options for saving the images (or obtaining physical dimensions) as there are 2 methods you can use:
1.) Enumerate IE cache for the image, copy it from there, load the image into an StdPicture object and retrieve the dimensions.
2.) Download the file yourself (perhaps with URLDownloadToFile() API) and repeat the StdPicture method from #1 to retrieve dimensions.
Form1:
-------------------------- -
'Project -> References... -> Microsoft HTML Object Library
Option Explicit
Private Sub Command1_Click()
Dim hDoc1 As HTMLDocument
Dim hDoc2 As HTMLDocument
'1 - load a web page
Set hDoc1 = New HTMLDocument
Set hDoc2 = hDoc1.createDocumentFromUr l("http://www.yahoo.com", vbNullString)
Do Until (hDoc2.readyState = "complete")
DoEvents
Loop
'2 - search the contents of the page to see if there are any pictures
If Not (hDoc2 Is Nothing) Then
Dim hImg As HTMLImg
For Each hImg In hDoc2.images
'3 - for pictures, determine the picture type, physical
' dimensions, size and any link that it may contain
Debug.Print hImg.mimeType 'type
Debug.Print hImg.src 'source
Debug.Print hImg.fileSize 'size
Debug.Print vbNullString
Next
End If
End Sub
1.) Enumerate IE cache for the image, copy it from there, load the image into an StdPicture object and retrieve the dimensions.
2.) Download the file yourself (perhaps with URLDownloadToFile() API) and repeat the StdPicture method from #1 to retrieve dimensions.
Form1:
--------------------------
'Project -> References... -> Microsoft HTML Object Library
Option Explicit
Private Sub Command1_Click()
Dim hDoc1 As HTMLDocument
Dim hDoc2 As HTMLDocument
'1 - load a web page
Set hDoc1 = New HTMLDocument
Set hDoc2 = hDoc1.createDocumentFromUr
Do Until (hDoc2.readyState = "complete")
DoEvents
Loop
'2 - search the contents of the page to see if there are any pictures
If Not (hDoc2 Is Nothing) Then
Dim hImg As HTMLImg
For Each hImg In hDoc2.images
'3 - for pictures, determine the picture type, physical
' dimensions, size and any link that it may contain
Debug.Print hImg.mimeType 'type
Debug.Print hImg.src 'source
Debug.Print hImg.fileSize 'size
Debug.Print vbNullString
Next
End If
End Sub
Oh, and if you'd like to try implementing #1, here are some resources:
GetUrlCacheEntryInfo:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcewinet/html/cerefGetUrlCacheEntryInfo.asp
Enumeration example:
http://vbnet.mvps.org/index.html?code/internet/findfirstcacheentry.htm
GetUrlCacheEntryInfo:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcewinet/html/cerefGetUrlCacheEntryInfo.asp
Enumeration example:
http://vbnet.mvps.org/index.html?code/internet/findfirstcacheentry.htm
ASKER
Is there any way that internet explorer can display the page being accessed at the time?
Also, is there any way that i can get the link that sits behind the image. eg. if you clicked on a picture and it went to www.google.com, how do i pick up that link?
Thanks.
Also, is there any way that i can get the link that sits behind the image. eg. if you clicked on a picture and it went to www.google.com, how do i pick up that link?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER