0

I am doing some automation on IE browser. On this i am logging into the web application and after logging when i am clicking on botton the web opens a new tab where i need to enter the data onto the textbox but here i am getting an error 438. below is my code. please help me out. i highlighted the line in bold where i am getting an error. The last one i am clicking on end tab and i am getting an error on that

Sub upload()
Dim myValue As Variant
Dim IETab1Number As Integer
Dim IETab2Number  As Integer
Dim IETab3Number As Integer
' open IE, navigate to the desired page and loop until fully loaded
    Set IE = CreateObject("InternetExplorer.Application")
    my_url = "http://englogin.sbc.com/ELP/"
    With IE
        .Visible = True
        .Navigate my_url
        .Top = 50
        .Left = 530
        .Height = 400
        .Width = 400
    Do Until Not IE.Busy And IE.readyState = 4
        DoEvents
    Loop
    End With
    ' Input the userid and password
    IE.document.getElementById("GloATTUID").Value = "Zf9775"
    IE.document.getElementById("GloPassword").Value = "MrsCooper$99"
    ' Click the "Login" button
    IE.document.getElementById("GloPasswordSubmit").Click
    Do Until Not IE.Busy And IE.readyState = 4
        DoEvents
    Loop
     ' Click the "Continue" button
     IE.document.getElementById("successButtonId").Click
    Do Until Not IE.Busy And IE.readyState = 4
        DoEvents
    Loop
    ' Click the "MIC" button
    IE.document.getElementById("btnMechanizedInventoryCreation").Click
    Do Until Not IE.Busy And IE.readyState = 4
        DoEvents
    Loop
   
    Set html = IE.document
    html.querySelector("a[href='#MIC']").Click
    IE.document.querySelector("[name=telco11iProjectNumber]").Value = "123456"
    ' Enter JOB Number" button
    'myValue = InputBox("Give me some input")
    

End Sub
  • 1
    Welcome to SO. It seems like you have forgotten to include your code, please edit your question to include your code (and the relevant HTML) – Raymond Wu Mar 21 '22 at 05:27
  • Please look into my problem guys. help me out – Puneet Singh Mar 23 '22 at 15:40
  • 1) Which line did the error 438 occur? I don't see any line being bolded and also, what is the error description? 2) Where's the relevant HTML? – Raymond Wu Mar 24 '22 at 04:38
  • Set html = IE.document html.querySelector("a[href='#MIC']").Click IE.document.querySelector("[name=telco11iProjectNumber]").Value = "123456" This line of code run on new tab – Puneet Singh Mar 24 '22 at 13:33
  • Or let me know how we can attach the tab like in automation after login a next tab open and there when i am selecting any element it throwing an error to me "" Runtime error 438". Let me know how i can attach browser in my code. – Puneet Singh Mar 24 '22 at 13:41
  • Try reading this [answer](https://stackoverflow.com/questions/38859727/vba-choosing-specific-tab-on-internet-explorer) and see if you can adopt it. @PuneetSingh – Raymond Wu Mar 24 '22 at 13:48
  • I already saw this but how i implement this on my code. In starting i need to login onto web and after login when i click on MIC button it navigate to new tab and there i face issue. so How i implement your suggested code into my existing one – Puneet Singh Mar 24 '22 at 16:58
  • Please someone look into this. – Puneet Singh Mar 26 '22 at 15:52
  • 1) Find out what's the URL of the new tab; 2) Copy/paste `GetIE` function from the linked answer to your module; 3) In your code, after you open the new tab, declare a new object variable (or you can reuse `IE` if you have no use for the old tab, you might want to close it first ) and set it to `IE([url of the new tab])` just like its shown in the answer. 4) declare a new object and set to the new IE's `.document` object and continue with your existing code. – Raymond Wu Mar 27 '22 at 03:07

0 Answers0