Check URL string if it contains Certain word

ian0886

New Member
Joined
Dec 10, 2016
Messages
42
Hi, i'm trying to go to a certain webpage. If its already logged in, it does some actions. If its not logged in, it logs in before executing the actions. But i need the VBA to search if the upon going to the webpage, it asks for my login details below is wat i've already written.


Code:
 Sub insert1()
    Set ie = CreateObject("InternetExplorer.Application")
    my_url1 = "https://xyz.com/admin/createib.php"
    my_url2 = "https://xyz.com/admin/createprofile.php"
    
    With ie
        .Visible = True
        .Navigate my_url1
        
    Do Until Not ie.Busy And ie.readyState = 4: DoEvents: Loop
    
    End With
    
    If ie.URL.ToString().Contains("login") Then 'this is where i got an error msg " Object doesn't support this property or method"
    ie.document.getElementById("login").Value = Sheets("PW").Range("B8")
    ie.document.getElementById("password").Value = Sheets("PW").Range("C8")
    ie.document.getElementById("login-btn").Click
    Do Until Not ie.Busy And ie.readyState = 4: DoEvents: Loop
    End If
    
    ie.Navigate my_url1
    
    With ie.document
        .getElementById("username").Value = Sheets("IB Profile").Range("B8")
        .getElementById("password").Value = Sheets("IB Profile").Range("B11")
        .getElementById("name").Value = Sheets("IB Profile").Range("B7")
        .getElementById("lname").Value = " "
        .getElementById("email").Value = Sheets("IB Profile").Range("B10")
        .getElementById("ibcode").Value = Sheets("IB Profile").Range("B9")
        .getElementById("region").Value = "Asia"
        .getElementById("country").Value = Sheets("IB Profile").Range("C6")
        .getElementById("currency").Value = "USD"
        .getElementById("balance").Value = "0"
        .getElementById("IB").Value = Sheets("IB Profile").Range("d6")
        .getElementById("submitchanges").Click
    End With
    
    Do Until Not ie.Busy And ie.readyState = 4: DoEvents: Loop
   
    ie.Navigate my_url2
    
End Sub

thanks in advance
Ian
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,213,483
Messages
6,113,919
Members
448,533
Latest member
thietbibeboiwasaco

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