Sendkey ("{ENTER}")
not entering data into website from excel
I need to use it since form does not have a button to click
Sub FillInternetForm()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://reference.medscape.com/drug-interactionchecker"
IE.Visible = True
While IE.Busy
DoEvents
Wend
Set TrackID = IE.Document.getelementbyid("MDICtextbox")
TrackID.Value = "Aspirin"
IE.Visible = True
SendKeys ("{ENTER}")
End Sub
Note that, if I change enter to other command such as {BS}
or Backspace it works but not enter
As a rule of thumb, If you are using
SendKeys
, you are doing something wrong.SendKeys
is an extremely fragile function, and there are usually other "programmatic" methodsMy Advice: Use the Page's javascript
I analyzed
http://reference.medscape.com/drug-interactionchecker
for you,It turns out that the
handleKeyDown
function is bound to theonkeydown
event,You can simply simulate the
{ENTER}
key by calling it directly(You can verify that it works by typing it in your browser's console)
You could call the function from vba with: