I've written a macro which navigates to a webpage. How can I let the macro wait i.e Idle State until the user enters a 'value' into the search box? I found an example online but I dont know how to modify it as the user has to enter multiple keystrokes. Any insight would be really helpful. Thanks!
[SIZE=12px]
Code
#If VBA7 Then 'declare virtual key event listener Private Declare PtrSafe Function GetAsyncKeyState Lib "user32" _ (ByVal vKey As Long) As Integer#Else 'declare virtual key event listener Private Declare Function GetAsyncKeyState Lib "user32" _ (ByVal vKey As Long) As Integer#End IfPrivate Const VK_F9 = &H78
[/SIZE]
[SIZE=12px]
Code
Sub GetDataFromMoneyControl() Dim SW As SHDocVw.ShellWindows Dim IE As SHDocVw.InternetExplorer Dim Sh As Worksheet Dim Url As String Dim TUrl As MSHTML.HTMLDocument Url = "http://www.moneycontrol.com/" Set Sh = ActiveWorkbook.ActiveSheet Set SW = New SHDocVw.ShellWindows Set IE = New SHDocVw.InternetExplorerMedium IE.Visible = True IE.Navigate Url ' Wait till the Internet Explorer has finished loading Do While IE.ReadyState <> READYSTATE_COMPLETE Loop ' Stores a reference to the HTML Document in that variable Set TUrl = IE.Document ' Wait for document to load If TUrl.ReadyState = "complete" Then ' [B]Search box where I need to enter data (this is where I need to tell the macro to wait)[/B] TUrl.getElementsByTagName("input")(4).Value End Sub
[/SIZE]