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>
  
 
David

That wasn't really a correction, that part of the code is waiting for the 'document' to be ready not IE which is sometimes needed.

It worked for me, but it could hang for others and why it hangs can depend on various things - connection, IE version, how the page has been designed etc.

I've never found a reliable method to deal with it and sometimes a hard timed delay is the only thing that works.

Mind you I don't like using a hard timed delay because, well, the delay is hard timed.:)
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,460
Messages
6,124,949
Members
449,198
Latest member
MhammadishaqKhan

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