0

I run into a weird problem when trying to automate inserting data into a website. Specifically one input field, here is html piece of that website:

<input class="maskAcctNbr" id="masked_consumer" type="text" size="20" maxlength="20" value="" autocomplete="off">

When I will insert value into that field using this code and click on "Lookup" button:

Dim SE As MSHTML.IHTMLElement
Set SE = HTMLDoc.getElementById("masked_consumer")
SE.Value = "574844"

The page is telling me that I'm missing information.

After I will manually click on that field and enter that number, the underlying html code changes to:

<input class="maskAcctNbr" id="masked_consumer" type="text" size="20" maxlength="20" value="" autocomplete="off" real="574844">

New real property shows up. Any ideas how I can solve that using VBA? I tried, click and focus, and nothing really works, until I use mouse to click on that field and manually enter that number.

Thank you!

2
  • Can you share the url? Commented Jun 10, 2019 at 16:20
  • @QHarr unfortunately it's not a public one. Commented Jun 10, 2019 at 16:25

2 Answers 2

1

Try to refer example below may help you to solve the issue.

Example:

Sub demo()

Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")

IE.navigate "http://example.com"

IE.Visible = True

While IE.Busy

DoEvents

Wend

Set TrackID = IE.document.getElementById("masked_consumer")
TrackID.Focus

Application.SendKeys ("(574844)"), True
Application.SendKeys ("{ENTER}"), True


End Sub
Sign up to request clarification or add additional context in comments.

4 Comments

I'm getting Run-time error '-2147352319 (80020101)' Automation error...
On this line: ie.document.parentWindow.execScript "handleKeyDown({which:13, preventDefault:function(){}});"
It worked, but I was really hoping not to use SendKeys I used it in combination with AppActivate "Internet Explorer". If no one will come up with something that doesn't involve that command I will mark it as answered! Thank you, for your help!
Actually we don't know that what events and functions are on your web page which get executed when you enter the data. So it is hard for us to guess it and test it. if you provide any kind of sample which can replicate the issue than we can try to make some tests with it.
0

I ran into a similar issue one time, and activating .OnClick event of that field helped. In your case it would be SE.onclick before setting the value. There can also be some other events such as OnChange that may result in "no data entered" errors, when they are not triggered. Good luck :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.