dcsimg
Results 1 to 2 of 2

Thread: [RESOLVED] Web scraping in web browser in UserForm

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2018
    Posts
    38

    Resolved [RESOLVED] Web scraping in web browser in UserForm

    I have web browser in UserForm and would like to automate the procedure for button in UserForm. So once user clicks button on UserForm with browser window code should do web scraping. This works if it is not in UserForms web browser. So now when this is inside UserForm it does the code until:

    Code:
     Application.Wait (Now + TimeValue("0:00:04"))
    
        .Document.querySelector("[name=import_budgets]").Click
    After that I am getting an error on .Document.querySelector("[name=import_budgets]").Click. Also web browser is not "refreshing" (moving to next page), I see it has been done .Document.querySelector(".data .a_1_611").Click and moved to next page only after receiving an error. Web browser do operations but they are not visible to user, probably that's why it can't proceed to next operation. How to make this work correct?

    Code:
       With LCountry.WebBrowser1
    
        Application.Wait (Now + TimeValue("0:00:02"))
    
        If ThisWorkbook.Sheets("Other Data").Range("AL21").Value = 2 Then
    
        .Document.querySelector(".data .a_1_611").Click
    
        Else
    
        .Document.querySelector(".data .a_1_610").Click
    
        End If
    
        Application.Wait (Now + TimeValue("0:00:04"))
    
        .Document.querySelector("[name=import_budgets]").Click
    
    'Unload IE
    
        If Err <> 0 Then
    
           MsgBox "There was an error running the code. Check your Internet and VPN connection. Please try one more time!"
           Else
    
        End If
    
        On Error GoTo 0
    End With
    Name:  Ehz2z.jpg
Views: 60
Size:  21.4 KB
    Last edited by mrwad; Jun 12th, 2019 at 01:39 AM.

  2. #2

    Thread Starter
    Member
    Join Date
    Oct 2018
    Posts
    38

    Re: Web scraping in web browser in UserForm

    This issue was solved by adding:

    Code:
        While .Busy
          DoEvents
        Wend
        While .ReadyState <> 4
          DoEvents
        Wend
    To each Web scraping operation in code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width