Library code snippets

Advancing the Webbrowser Control

You need to have "HTML Object Library" in the References window, and a webbrowser control (Microsoft Internet Controls). Once you've inserted this code into your project, you'll notice a new object in the Code window called mdocDocument. It has lots of events, such as: Click, Double Click, Mouse Move, KeyUp, KeyDown and lots more...

Place the following code in the General Declarations section

Private mhtmDoc3 As IHTMLDocument3
Private WithEvents mdocDocument As HTMLDocument

' When navigating to a new page, update the Object we're monitoring
Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
  Set mhtmDoc3 = WebBrowser1.Document
  Set mdocDocument = mhtmDoc3
End Sub

Comments

  1. 01 Sep 2004 at 03:31
    Thanks a lot for the information given, it really helped me
  2. 07 Apr 2003 at 16:35
    You can click buttons or links and submit forms using javascript.

    Click a link:  Browser1.Navigate "javascript:document.links[1].click();"
    Submit a form: Browser1.Navigate "javascript:document.formName.submit();"

    If you read more about the DOM and javascript you can do almost anything using the browser control.  You can experiment with this javascript by just typing it into the address bar.
  3. 15 May 2002 at 05:17
    This is very useful if you want full control over the control and what's going on! but do you know how I can click a button of an html form within a document? I can't find anything about this on the net :(
  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Advancing the Webbrowser Control.

Leave a comment

Sign in or Join us (it's free).

Kym Manson Till the Roof comes off Till the Lights go out Till my Legs give out Can't shut my mouth I will not fall, my Wisdoms all.

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

We'd love to hear what you think! Submit ideas or give us feedback