We help IT Professionals succeed at work.

VBA get html tag from html page

JoelRidley
JoelRidley asked
on
Medium Priority
498 Views
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
Comment
Watch Question

Commented:
Here's an articlke on using the Inet Control.

http://support.microsoft.com/default.aspx?scid=kb;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.

Commented:
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://www.msn.com"

    ' Retrieve the HTML data into a byte array.
    strPage = objInet.OpenURL(objInet.URL, icString)
   
    x = 1
   
    Do
        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
        Else
            Exit Do
        End If
    Loop
   
    Debug.Print "All done!"
End Sub

Author

Commented:
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
Commented:
>>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....

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.