Re: Accessing an HTML document's objects

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Björn Holmgren (bjohol_at_hotmail.com)
Date: 06/16/04


Date: Wed, 16 Jun 2004 14:12:28 +0200


"Alan Lambert" <AlanLambert@discussions.microsoft.com> wrote in message
news:5EEDEBC5-3EF3-471F-AA49-2126FE923135@microsoft.com...
> I'm trying to access the contents of an HTML document using the object
model. I know this can be done by using the WebBrowser control but I don't
want to display the page, just navigate through it. Setting the WebBrowser
control's visible property to false seems to prevent access to the DOM.
>
> Can anyone suggest an alternative method?

How about creating an instance of the InternetExplorer.Application class?

Example:

    Const READYSTATE_COMPLETE = 4
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Navigate2 "http://specify.url.here"
    Do Until IE.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    ' You can now access the DOM through the IE.Document property
    IE.Quit
    Set IE = Nothing

--
Björn Holmgren
Guide Konsult AB


Relevant Pages

  • Re: Focus in webbrowser Control
    ... I'm using a webbrowser control in my project, ... You will have to manipulate the DOM (exposed as the webbrowser.Document ... exposes a Document property; it is the document object of the web page ... Giving focus to an element within an HTML document requires DOM-level calls; ...
    (microsoft.public.vb.controls)
  • Re: interact with IE/Webbrowser modal Save Webpage window from app that opened it, possible?
    ... Another option using IE itself would be to use the DOM ... | and then enter the filename and path in the "File name:" edit control, ... | When I use a webbrowser control or open a new IE window from the VB ... | send the filename and path to the 2nd VB program using a command line ...
    (microsoft.public.vb.general.discussion)
  • Document Complete event not firing on some machines.
    ... I am using webbrowser control in one VB program. ... But It is firing on some machines and not on some ... it is firing on my machine even though I have set visible property to False. ...
    (microsoft.public.vb.controls.internet)
  • Re: Searching web sub-pages
    ... into a WebBrowser control or IE instance). ... weren't thinking of using DOM to look for the keywords. ... so as to avoid the bloat of loading them ... Then I would just parse them with InStr. ...
    (microsoft.public.vb.general.discussion)
  • Re: Windowless WebBrowser control?
    ... > If you don't require the rendering services of the WebBrowser control, ... > documents, which you can manipulate, add elements to, set element attributes ... I've used just the MSHTML parser before and the DOM returned isn't ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)