send keys not working in vba

sai123

New Member
Joined
Jan 14, 2017
Messages
1
Code:
Private Sub CommandButton1_Click()


Dim IE As Object
Dim objPage As Object
Dim wshshell As Object


Set IE = CreateObject("InternetExplorer.Application")


URL = "***"
IE.Visible = True
IE.Navigate URL

While IE.busy
DoEvents
Wend


Set wshshell = CreateObject("WScript.Shell")


newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 30
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime


wshshell.SendKeys "{F3}"


wshshell.SendKeys "n"
wshshell.SendKeys "a"
wshshell.SendKeys "m"
wshshell.SendKeys "e"

wshshell.SendKeys "{tab}"
wshshell.SendKeys "{tab}"
wshshell.SendKeys "test"

wshshell.SendKeys "{F3}"
wshshell.SendKeys "#"
wshshell.SendKeys "3"

End Sub

here I am trying to automate a web form, as the html code is hidden I am not able to use getelememtbyid methods.
And also I do not have access to spy++, so I an not use windows API calls.
And I am thing of using wscript object in vba .
In the code I am trying to do this:
Launch IE
Open the URL
now comes the problem, there are two dropdown objects
one is 'name' and other 'service #'
inorder to fill these dropdown, I have given find(F3) option to search for the dropdown name. and then pass the value test.
but, when I try running the code. It is not happening as expected.
Pls guide me.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,215,429
Messages
6,124,834
Members
449,192
Latest member
mcgeeaudrey

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