Screen scraping from Internet after submit (VBA)

SaskiaHe

New Member
Joined
Apr 14, 2009
Messages
20
Hello,

I'm trying to retrieve information from Internet. I'm opening the site, filling in a condition and press the button Deal. So far it works.

But then I'm trying to retrieve the information displayed on the website into VBA and sometimes that works and sometimes it doesn't.

It seems that most of the times VBA looses focus and Objie isn't valid anymore. objie.quit doesn't work either after the ele.click.


Can anybody help please?

Code:
Function pbnInternet(Condition)
Dim objIE As Object, ele As Object
Dim pos As Integer
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Visible = True
    objIE.navigate "http://www.bridgebase.com/tools/dealer/dealer.php"
    Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
    
    objIE.document.all("i").Value = Condition
    
    For Each ele In objIE.document.getElementsByTagName("input")
        If ele.Value = "Deal" Then
            ele.Click
            
            Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
            pbnInternet = objIE.document.body.innerHTML
    
            Debug.Print pbnInternet
            
            objIE.Quit
            
            pos = InStr(1, pbnInternet, "pre") 
            If pos > 0 Then pbnInternet = Mid(pbnInternet, pos + 5)
        
            Exit For
            
        End If
    Next ele
End Function
 
Last edited:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Some additional info: I also tried with sleep(1000) and even longer, but that doesn't help. So, I guess it is not that he page hasn't finished downloading yet.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top