我正在尝试触发我们在用户在输入字段文本中写入股票代码并按 Enter 时看到的事件
这条线有效:
ie.Document.all("ticker").innertext = "BBDCF230"
但就在按下回车键之后,网页将“BBDCF230”代码中的数据加载到其他字段中。我正在尝试使用:
Application.SendKeys "~" '## send the "Enter" keystroke
但它不工作。有任何想法吗?
Sub dxArray(ticker As String, ByRef premioEstimada() As truple, Optional mostrar As Boolean)
Dim ie As InternetExplorer
Set ie = New InternetExplorer
If mostrar = True Then
ie.Visible = True
Else
ie.Visible = False
End If
Application.StatusBar = "DX: " & ticker
ie.Navigate "https://opcoes.net.br/calculadora-Black-Scholes/" & ticker
Do While ie.Busy = True Or ie.ReadyState <> READYSTATE_COMPLETE 'Equivalent = .ReadyState <> 4
Application.Wait (Now + TimeValue("00:00:01")) 'Wait 1 second, then check again.
Loop
ww1 = ie.Document.all("premioDaOpcao").Value
For i = 0 To UBound(premioEstimada)
ie.Document.all("ticker").innertext = ""
ie.Document.all("ticker").innertext = "BBDCF230"
Application.SendKeys "~" '## send the "Enter" keystroke
ie.Document.all("cotacaoAcao").innertext = Replace(CStr(premioEstimada(i).cotacao), ".", ",")
ie.Document.all("btncalcular").Click
Do While ie.Busy = True Or ie.ReadyState <> READYSTATE_COMPLETE Or ie.Document.all("premioDaOpcao").Value = "" 'Equivalent = .ReadyState <> 4
Application.Wait (Now + TimeValue("00:00:01")) 'Wait 1 second, then check again.
Loop
premioEstimada(i).premioEstimado = ie.Document.all("premioDaOpcao").Value
premioEstimada(i).ticker = ticker
Next i
ie.Quit
Set ie = Nothing`enter code here`
End Sub