Solved

Automation of IE6

Posted on 2006-06-26
7
671 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:sjeffress
[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
  • 3
  • 2
7 Comments
 
LVL 1

Author Comment

by:sjeffress
ID: 16990248
Oh, sorry.  I forgot an important point.  I am using VBA (access).
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 16995054
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.createDocumentFromUrl("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
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 16995070
0
 
LVL 1

Author Comment

by:sjeffress
ID: 16997071
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.
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 250 total points
ID: 16997749
>>Is there any way that internet explorer can display the page being accessed at the time?
Several different approaches available.

1.) Use the WebBrowser component (essentially it's just IE). You can then, instead of using createDocumentFromUrl(), access the WebBrowser's Document instance (WebBrowser1.Document).

2.) Use CreateObject() to create a new instance of IE which you can automate.

    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.navigate "www.yahoo.com"

You can thereafter access ie.Document after it has finished initializing.

3.) You can use ShellWindows to enumerate available IE instances and when you find the proper one, assume automation of it.

    'Project -> References -> Microsoft Internet Controls
    Dim ie As InternetExplorer
    Dim sw As New ShellWindows
    For Each ie In sw
        MsgBox ie.Document.body.outertext
    Next

>>is there any way that i can get the link that sits behind the image
Well, images and links are different elements within the DOM. An idea would be to...

Iterate through the Links collection and for each Link object, enumerate through its' children and see if any of them are Image elements. You can then compare that Image element against others or what-not.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

623 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