I Get object required error when using getElementByID

0 votes

I am trying to enter a Username into a text box Using getElementById. this generates an "Object required" Error

Dim Myid
Mypsw As String

Dim ie As InternetExplorer

Dim ErrCnt

On Error GoTo ErrorHandler

ChDir "C:\Users\hm_cl\Downloads"

Kill "History.txt"

Myid = "hmclark1959"

Mypsw = "xxxxxxxxx"


Set ie = New InternetExplorer
ie.Visible = True

ie.navigate "https://eteller.dakotalandfcu.com/Centryx/servlet/com.sos.webteller.accountaccess.LoginFrame"

While ie.Busy = True Or ie.readyState < 4: DoEvents: Wend

' ******** The following line generates the error

ie.document.getElementById("LoginID").Value = Myid

ErrorHandler:

MsgBox (Err.Description)

Select Case Err.Number
  Case 53  ' File not found

      Resume Next

  Case 424 ' Object Reuired

      ErrCnt = ErrCnt + 1

      If ErrCnt > 4 Then

        MsgBox (" Unknown Server Side Error")
        ie.Quit
        End

      Else

        Application.Wait (Now + TimeValue("0:00:10"))
        Resume

      End If

  Case Else   'Unknown error

    MsgBox ("There is an unhandled error")
    ie.Quit
    End

End Select

When I click inspect element on the textbox it says the ID="LoginID"

Jan 15 in Others by Kithuzzz
• 29,080 points
79 views

1 answer to this question.

0 votes

As you see LoginID is the id of the p tag but you need the input tag to enter your text. The input tag is the first child and then the first sibling in the dom tree from the p tag. Try this:

ie.document.getElementById("LoginID").firstChild.nextSibling.Value = Myid

Look here for further information:
firstChild
nextSibling
Something about the Document Object Model (DOM)

answered Jan 15 by narikkadan
• 53,920 points

Related Questions In Others

0 votes
1 answer

Get last modified object from S3 using AWS CLI

With aws s3 ls $BUCKET —recursive, you ...READ MORE

answered Mar 24, 2022 in Others by gaurav
• 22,960 points
2,673 views
0 votes
0 answers
0 votes
1 answer
0 votes
1 answer

Using unserialize in PHP throws the same error repeatedly

I googled 'Node no longer exists', and ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,240 points
905 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
533 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,415 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 22,960 points
117 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,630 points
300 views
0 votes
1 answer

Excel formula gives error when write using Apache-poi library in Java

I tested some sample code. The cell ...READ MORE

answered Nov 5, 2022 in Others by narikkadan
• 53,920 points
247 views
0 votes
1 answer

How do I get an Excel range using row and column numbers in VSTO / C#?

Use: int countRows = xlWorkSheetData.UsedRange.Rows.Count; int countColumns = xlWorkSheetData.UsedRange.Columns.Count; object[,] ...READ MORE

answered Nov 17, 2022 in Others by narikkadan
• 53,920 points
210 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP