Could Not find Textbox by ID in excelVBA

VenkatesanPR

New Member
Joined
Jul 24, 2020
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
im not good in coding i tried getElementByID and TagName ClassName but couldn't find newplate id "ctl00_Contentplaceholder_txtNewPlate" how enter value in newplate textbox and click search button by excel vba .


i tried the following vba code to get the id names but it returned login form textbox id.
please help me. thanks in advance

VBA Code:
Sub IE_Autiomation()
    Dim i As Long
    Dim IE As Object
 

    ' Create InternetExplorer Object
    Set IE = CreateObject("InternetExplorer.Application")
 
    ' You can uncoment Next line To see form results
    IE.Visible = True
    

 
 Dim Login, WOSearch, FMenu As String
    Login = "http://10.10.10.232/FMS/Login.aspx"
    FMenu = "http://10.10.10.232/FMS/FleetMenu.aspx"
    WOSearch = "http://10.10.10.232/FMS/Search/FleetWOSearch.aspx"
    
       
IE.Navigate Login

Do
Loop Until IE.ReadyState = READYSTATE_COMPLETE

        IE.Document.getElementById("txtUserId").Value = "sajed"
        IE.Document.getElementById("txtPassword").Value = "Password1"

IE.Document.getElementById("imgbntOK").Click

    ' Send the form data To URL As POST binary request
    IE.Navigate WOSearch
     
Dim divs As Object
Dim div As Object

Set divs = IE.Document.getElementsByClassName("textbox")
i = 0
For Each div In divs

    If div.ID = "ctl00_Contentplaceholder_txtNewPlate" Then
    div.innerText = "16/97214"
    End If
    i = i + 1
    Sheets("Sheet2").Range("A" & i) = div.ID & i
Next
Set divs = IE.Document.getElementsByClassName("textbox")
i = 0
For Each div In divs

    If div.ID = "ctl00_Contentplaceholder_txtNewPlate" Then
    div.innerText = "16/97214"
    End If
    i = i + 1
    Sheets("Sheet2").Range("A" & i) = div.ID & i
Next
    ' Show IE
    IE.Visible = True
 
    ' Clean up
    Set IE = Nothing
 
    Application.StatusBar = ""

End Sub


please share email address to send the pagecode 


[URL]http://10.10.10.232/FMS/Search/FleetWOSearch.aspx[/URL]
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    215.7 KB · Views: 6

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Playing with HTML can be very tricky. It's hard to fix this without seeing the actual page.

I would try stepping through line by line with F8 to see exactly where the code is going wrong. Then it's a case of googling and playing around to find the problem.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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