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: 3

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Dermot

Board Regular
Joined
Aug 11, 2006
Messages
73
Office Version
  1. 365
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,193
Messages
5,546,481
Members
410,742
Latest member
WalterSil
Top