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

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Dermot

Board Regular
Joined
Aug 11, 2006
Messages
199
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,118
Messages
5,835,492
Members
430,359
Latest member
ManuelCukRia

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
Top