How to refresh ButtonPage in VBA for Internet Explorer

inuyasha

New Member
Joined
Jun 30, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,
I wanna ask about vba for internet explorer automation
I use it on e-commerce web (shopxx) to scrape buyer link from other seller.
I have made script & it worked but I have a problem to refresh the Button object.

The step is:
- open IE for other seller rating page
- grab all the link & all button page
- open the new link in new IE
- follow them, close the new IE and looping per page

Since there only 5 button page when I first load the page, I try to repeat it.
in this code I try to repeat 2x (I use **FOR looping with variable varRepeat**).

what I want to ask is: <br>
- after clicking 5 page (5 button has been clicked) => worked
- when varRepeat=2
why the BtnPage didn't refresh to page 6-9, and it's still refer to button page 1-5 (on the 1st loading page).

eventhough I have place this command
Set ieBtnPage = objIE.Document.getElementsByClassName("shopee-button-no-outline")

So the program running for page 1, 2, 3, 4, 5, and back to 1, 2, 3, 4, 5

Thank you.


VBA Code:
Sub Followers()
 
    Dim objIE As InternetExplorer
    Dim ieAnchors As Object
    Dim Anchor As Object
    Dim ieBtnPage As Object
 
    Set objIE = New InternetExplorer
 
    objIE.Visible = True
    objIE.Navigate "https://shoxxe.co.id/buyer/xxxxx/rating"
    
    Do While objIE.Busy = True Or objIE.ReadyState <> 4: DoEvents: Loop
    Application.Wait (Now + TimeValue("0:00:3"))
    
    varRepeat = 1  
    For varRepeat = 1 To 2
    
    Set ieBtnPage = objIE.Document.getElementsByClassName("shopee-button-no-outline")

      For Each BtnPage In ieBtnPage
           
         For Each Anchor In ieAnchors
            result = Anchor
                             
                       Dim objIE_1 As InternetExplorer
                       Dim ieBtn As Object
                       Dim Btn As Object
                   
                       Set objIE_1 = New InternetExplorer
                   
                       objIE_1.Visible = True
                       objIE_1.Navigate Anchor
                    
                       Do While objIE_1.Busy = True Or objIE_1.ReadyState <> 4: DoEvents: Loop
                       Application.Wait (Now + TimeValue("0:00:3"))                   
                
                       Set ieBtn = objIE_1.Document.getElementsByClassName("shopee-button-outline shopee-button-outline--complement shopee-button-outline--fill ")
                          
                       Do While objIE_1.Busy = True Or objIE_1.ReadyState <> 4: DoEvents: Loop
        
                              For Each Btn In ieBtn
                              Btn.Click
                              Next Btn
                      
                      Application.Wait (Now + TimeValue("0:00:2"))
                      objIE_1.Quit
                 
         Next Anchor
      
      BtnPage.Click
    
      Next BtnPage
 
    Next varRepeat

 
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Case Closed.
The problem aforementioned was my mistakes.
It happened due to in page 5, the button shown in page start from 1 to 7, while it only marked active page (5).
So rather using button page, I used next button & I repeat it using loop for any amount I want.
Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,537
Messages
6,120,096
Members
448,944
Latest member
SarahSomethingExcel100

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