VBA get html tag from html page

Posted on 2006-03-25
Last Modified: 2008-03-10
Hello Expert,
Using MSAccess how can I get thename of an image or images from the html page I am viewing and then save this image data to a table. I am creating a new webbrowser (IE6) from Access. Thank you, Joel
Question by:JoelRidley
    LVL 18

    Expert Comment

    Here's an articlke on using the Inet Control.;EN-US;q163653

    Once you have the page in a text documnet all you need to do is search for the IMG tags and parse out the data you're after.
    LVL 18

    Expert Comment

    Curisoity got the best of me... here's a short example that will pull all of the IMG tags from a page. Create a new form, place a comand button on it called cmdGetAsString and place this code in it's click event. And insert the Microsoft Internet Transfer Control from Insert - ActiveX Control on your form and you're all set to test.

    Private Sub cmdGetAsString_Click()
        Dim strPage As String, x As Long, y As Long
        ' Set a reference to the internet transfer control.
        Set objInet = Me.Inet0.Object
        ' Set the internet transfer control protocol and URL.
        objInet.Protocol = icHTTP
        objInet.URL = "HTTP://"

        ' Retrieve the HTML data into a byte array.
        strPage = objInet.OpenURL(objInet.URL, icString)
        x = 1
            x = InStr(x, strPage, "<img src")
            If x <> 0 Then
                y = InStr(x + 5, strPage, ">")
                Debug.Print Mid(strPage, x, y - x + 1)
                x = x + 1
                Exit Do
            End If
        Debug.Print "All done!"
    End Sub

    Author Comment

    p912s I thank you for the help but am unable in insert Inet. I use shddocdl.dll to start IE6. I should have explained better, the wife is always deleting her images and then redownloading them.Its an older laptop and I don't let her on my system after she crashed it. She is not to computer savvy, I just wanted to make a table of here favorites and then all shehas to do s click a button to save the ihnfo in a table
    thanks, Joel
    LVL 18

    Accepted Solution

    >>use shddocdl.dll to start IE6
    Do you mean shdoclc.dll and not shddocdl.dll ? I'm not familiar with using this? The Internet Transfer Control is MSINET.OCX and can be used to transfer pages without viewing them. And the WebBrowser Control is part of the Microsoft Internet Controls SHDOCVW.DLL and can be used to view pages in Access.

    >>always deleting her images and then redownloading them
    >>just wanted to make a table of here favorites
    How are these related? Favorites & images? An image of a page in history? A jpg or gif displayed on a page? How are favorites related to this?

    As you can see I'm confused as to what you're problem is and what you're really trying to accomplish....

    Author Comment

    What I want to do is when she is at a webpage with the images she wanys is to click a button on a form and that will gather all the image names and put them in a table which she can then later download. the only part I haven't worked out is getting the file names from the webpage thanks again Joel

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    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…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now