Click here to Skip to main content
13,198,465 members (58,125 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
when I try to execute this code doc = appIE.document it is throwing error like comexception was unhandled...plz help me..
How to handle it



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim appIE As Object 'InternetExplorer
appIE = Nothing

Dim doc As HtmlDocument
'Dim appIE As Object = CreateObject("InternetExplorer.Application")
If appIE Is Nothing Then appIE = CreateObject("InternetExplorer.Application")
Dim URL = "https://www.facebook.com/souj.shanigaram/"
'Dim doc As HtmlDocument = appIE.document


With appIE
.Navigate(URL)
.Visible = True
End With

doc = appIE.document
For Each obj In doc.GetElementsByTagName("a")
If obj.innerText = "About" Then
obj.Click()
Exit For
End If
Next

What I have tried:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim appIE As Object 'InternetExplorer
        appIE = Nothing
 
        Dim doc As HtmlDocument
        'Dim appIE As Object = CreateObject("InternetExplorer.Application")
        If appIE Is Nothing Then appIE = CreateObject("InternetExplorer.Application")
        Dim URL = "https://www.facebook.com/souj.shanigaram/"
        'Dim doc As HtmlDocument = appIE.document
 

        With appIE
            .Navigate(URL)
            .Visible = True
        End With
 
        doc = appIE.document
        For Each obj In doc.GetElementsByTagName("a")
            If obj.innerText = "About" Then
                obj.Click()
                Exit For
            End If
        Next
Posted 12-Oct-17 6:08am
Updated 12-Oct-17 6:34am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The Navigate method[^] starts navigation to the specified page, and returns immediately. It does not wait for the navigation to complete.

You cannot access the document until the page has finished loading. You'll either need to wait for the NavigateComplete event[^] to fire, or wait for the Busy property[^] to return False.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.171020.1 | Last Updated 12 Oct 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100