У меня есть следующий код Excel VBA, который отправляется на веб-сайт OFAC, выполняет запрос, а затем возвращает результат в таблицу Excel.Код хорошо работал в прошлом.Однако сегодня новый пользователь попытался использовать этот код и получил следующую ошибку:
Сбой метода Busy of WebBrowserii.
Ниже приведен проблемный код: While ie.Busy
.
Кто-нибудь знает причину проблемы и, что более важно, как ее исправить?
Sub GetOFAC()
Dim strResults As String
Dim ofacname As String
ofacname = Excel.Range("Company").Value
Application.ScreenUpdating = False
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "https://sanctionssearch.ofac.treas.gov/"
ie.Fullscreen = True
Application.StatusBar = "Submitting"
' Wait while IE loading...
While ie.Busy
DoEvents
Wend
' **********************************************************************
delay 1
ie.Document.getElementById("ctl00_MainContent_txtLastName").Value = ofacname
delay 1
ie.Document.getElementById("ctl00_MainContent_btnSearch").Click
Application.SendKeys "(%{1068})"
'**********************************************************************
Application.StatusBar = "Form Submitted"
'Wait while the results load
Application.Wait (Now + TimeValue("0:00:02"))
'The results have loaded so select the table and get the text
strResults = ie.Document.getElementById("scrollResults").InnerText
'MsgBox strResults
ie.Quit
Set ie = Nothing
'The results have loaded so select the table and get the text
Application.Goto Reference:="ofac_drop"
ActiveCell.Value = Trim(LTrim(RTrim(strResults)))
Application.Goto Reference:="OFCA_LANDING"
ActiveSheet.Paste
Application.Goto Reference:="start"
End Sub