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, 2023 in Others by Kithuzzz
• 38,020 points
923 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, 2023 by narikkadan
• 63,720 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
• 23,260 points
4,691 views
0 votes
0 answers
0 votes
0 answers

Why does Excel give me a #NAME? error when I open this CSV file?

The CSV file consists of two lines: ...READ MORE

Apr 10, 2023 in Others by Kithuzzz
• 38,020 points
393 views
0 votes
1 answer
0 votes
1 answer

To automatically print in excel but nothing happens

This is a revised version of your ...READ MORE

answered Feb 21, 2023 in Others by narikkadan
• 63,720 points
526 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
1,096 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
3,512 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
• 23,260 points
820 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
• 63,720 points
1,847 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
• 63,720 points
1,653 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