VBA - IE automation text field input RTE 438

David44

New Member
Joined
Nov 11, 2013
Messages
13
Hi

I'm trying to Automate IE with VBA and am running into an issue I've yet to find a solution to.
My code fails to input the desired text into the text field box. I don't think the code can even find the text box I want it to, it may have someting to do with Javascript and tables. Please take a look and let me know the best method to get this done.

Here is my code.

Rich (BB code):
Sub Placer_PDF()
Dim IE As Object
Dim url As String
Dim tags As Object
Dim tagx As Object
 
'load internet explorer
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
'go to property tax website
url = "https://common3.mptsweb.com/megabyt...aspx?CN=placer&Dept=Tax&Site=Public&PG=Search "
IE.navigate url
'wait for page to load
Do
DoEvents
Loop Until IE.readystate = 4

'Input parcel # into website
IE.Document.all("idAsmt").Value = 44444
'Çlick on the submit button
For Each tagx In tags
    If tagx.Name = "Submit" Then
        tagx.Click
    End If
Next

End Sub


And here is the Website Source.

HTML:
<
 

b>b>

 
<
 
 
br/>

 
 
 
xmlversion="1.0"encoding="utf-8"?>

 
          
 
DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 
      
 
<html><head><title>Inquirytitle>******http-equiv="Content-Type"content="text/html; charset=utf-8"/><linkrel="stylesheet"href="../Placer/WebInquiry/CSS/search.css"type="text/css"/><linkrel="stylesheet"href="Placer/WebInquiry/CSS/menus-simple.css"type="text/css"/>********type="text/javascript"language="javascript">script>********type="text/javascript"language="javascript"src="../Placer/WebInquiry/jscripts/ua.js">script>********type="text/javascript"language="javascript"src="../Placer/WebInquiry/jscripts/xbDebug.js">script>********type="text/javascript"language="javascript"src="../Placer/WebInquiry/jscripts/xbDOM.js">script>********type="text/javascript"language="javascript"src="../Placer/WebInquiry/jscripts/xbStyle.js">script>********type="text/javascript"language="javascript"src="../Placer/WebInquiry/jscripts/mbsMenuTree.js">script>********type="text/javascript"language="javascript"src="../Placer/WebInquiry/jscripts/common.js">script>********language="JavaScript"src="../_ScriptLibrary/RS.HTM">script>********language="javascript">script>********type="text/javascript"language="javascript"src="Placer/WebInquiry/jscripts/webinquiry.js">script>head><body><formname="frmMain"method="post"action="Inquiry.aspx?CN=placer&DEPT=Tax&SITE=Public&PG=taxresults"><tablecellspacing="0"cellpadding="0"width="380"><trclass="title"><tdcolspan="3"><i>Tax Inquiry: Please enter search criteriai>td>tr><trclass="titleRollYear"><tdcolspan="2"align="right">

 
                    Select Roll Year 

 
                
 
td><td><selectname="rollyear"><optionvalue="c">2013 -Current Yearoption><optionvalue="p">2012 -Previous Yearoption>select>td>tr><trclass="tr3search"><tdclass="searchfield">Feeparcel #td><tdclass="searchtype"><selectname="cbfeeparcel"id="idfeeparcel"onchange=""><optionvalue="like">Begins withoption><optionvalue="endwith">Ends withoption><optionvalue="contains">Containsoption><optionvalue="=">Equal tooption><optionvalue="<>">Not equal tooption><optionvalue="<">Less thanoption><optionvalue=">">Greater thanoption>select>td><tdwidth="150"><inputclass="userinput"maxlength="24"onkeypress="js:return SubmitOnEnter(this,event)"name="idfeeparcel">input>td>tr><trclass="tr3search"><tdclass="searchfield">Assessment #td><tdclass="searchtype"><selectname="cbAsmt"id="idAsmt"onchange=""><optionvalue="like">Begins withoption><optionvalue="endwith">Ends withoption><optionvalue="contains">Containsoption><optionvalue="=">Equal tooption><optionvalue="<>">Not equal tooption><optionvalue="<">Less thanoption><optionvalue=">">Greater thanoption>select>td><tdwidth="150"><inputclass="userinput"maxlength="24"onkeypress="js:return SubmitOnEnter(this,event)"name="idAsmt">input>td>tr>table><p><inputtype="button"class="BasicButton"name="Submit"value="Submit"*******="javascript:SubmitForm();"/><inputtype="button"class="BasicButton"name="Clear"value="Clear"*******="javascript:ClearForm();"/><inputtype="hidden"name="edtargs"id="edtargs"value="?CN=placer&DEPT=Tax&SITE=Public">input>p>form>body>html>
  
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
There's more than one element with the id/name idAmst - the dropdown for search type, eg Begins with..., Contains.... etc, and the input field for the search term.

Actually, the dropdown has the id 'idAmst' and the name 'cbAsmt' whereas the input field has the id 'idAmst' and no name.

I don't know how the search works but I think you'll need to select a search type and enter a value.

PS To submit the form you can try this.
Code:
IE.document.forms(0).submit
 
Upvote 0
There's more than one element with the id/name idAmst - the dropdown for search type, eg Begins with..., Contains.... etc, and the input field for the search term.

Actually, the dropdown has the id 'idAmst' and the name 'cbAsmt' whereas the input field has the id 'idAmst' and no name.

I don't know how the search works but I think you'll need to select a search type and enter a value.

PS To submit the form you can try this.
Code:
IE.document.forms(0).submit



I tried the Button submit code you mentioned but it didn't hit the button, My previous method didn't work eather. Same error code 438. So now I have two issues.
The dropdown is already preset to what I need when the website loads so messing with it isn't a factor.

I just need to put text into the box and hit submit.
 
Upvote 0
Can you post the updated code?
 
Upvote 0
It's just about the same code as before but with your Submit button code insted of what I had previously. I commented out the other code giving me an error so I could test your button code. I is still giving be the same Error code, both with the button pressing and the form input box. 438 "Runtime error 438 Object doesn't support this property or method"



Code:
Sub Placer_PDF()
Dim IE As Object
Dim url As String
 
'load internet explorer
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
'go to property tax website
url = "[URL]https://common3.mptsweb.com/megabytecommonsite/(zmimzpfj0i3tl2bjijk4lu3d)/PublicInquiry/Inquiry.aspx?CN=placer&Dept=Tax&Site=Public&PG=Search[/URL] "
IE.navigate url
'wait for page to load
Do
DoEvents
Loop Until IE.readystate = 4

'Input parcel # into website
'IE.Document.all("idAsmt").Value = 44444
'  ^^^I still need the above code fixed, but commented it out to test the Submit code below.

IE.Document.forms(0).submit
End Sub
 
Upvote 0
The submit code works, though no records are found for 44444.
Code:
Sub Placer_PDF()
Dim IE As Object
Dim url As String

    'load internet explorer
    Set IE = CreateObject("internetexplorer.application")
    IE.Visible = True
    'go to property tax website
    url = "https://common3.mptsweb.com/megabytecommonsite/(zmimzpfj0i3tl2bjijk4lu3d)/PublicInquiry/Inquiry.aspx?CN=placer&Dept=Tax&Site=Public&PG=Search"
    IE.navigate url
    'wait for page to load
    Do
        DoEvents
    Loop Until IE.readystate = 4

    'Input parcel # into website
    IE.Document.all("idAsmt")(1).Value = 44444
    IE.Document.forms(0).submit

End Sub
 
Upvote 0
Wow, thank you. I've updated it with a random property tax number that works. It still isn't pressing the Submit button on my end though.
It is inserting the number, which is great.

What is the signifignace of the (1) and (0) that you added?

Rich (BB code):
Sub Placer_PDF()
Dim IE As Object
Dim url As String
    'load internet explorer
    Set IE = CreateObject("internetexplorer.application")
    IE.Visible = True
    'go to property tax website
    url = "https://common3.mptsweb.com/megabyt...aspx?CN=placer&Dept=Tax&Site=Public&PG=Search"
    IE.navigate url
    'wait for page to load
    Do
        DoEvents
    Loop Until IE.readystate = 4
    'Input parcel # into website
    IE.Document.all("idAsmt")(1).Value = "036-260-017-000"

    IE.Document.forms(0).submit
End Sub
 
Upvote 0
Since there's more than one element with the name/id 'idAsmt' IE.document.all("idAsmt") returns a collection.

The collection has a 0-based index which means the first item is IE.Document.all("idAsmt")(0), the second IE.Document.all("idAsmt")(1) and so on.

In this case the element we want is the second item so we use IE.Document.all("idAsmt")(1).

Similarly IE.Document.forms returns a collection of all the forms in the document.

We want the first (and only) one so we use IE.Document.forms(0).

Hope that makes sense.:)

By the way, that code works just fine for me and a record is returned.

Do you get any errors?
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,541
Members
449,089
Latest member
davidcom

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