当excel VBA代码将值传递给IEobject时,我会间歇性地面对运行时Error 91。比如说,对于一组15次迭代,我在同一位置遇到了3-4次错误。
当我手动(F8)运行时,看不到错误。我添加了延迟,但徒劳无功。
在输入货币之前,Acct_name字段一直呈灰色显示。IE.document.frames("company").document.forms("account").document.all("currency").Value="USD“IE.document.frames("company").document.forms("account").document.all("currency").fireevent("onblur")
...delay在这里
DO while IE.document.frames("company").document.forms("account").document.all.("acct_name").Readystate<>"complete“的间歇性运行时错误91循环
IE.document.frames("company").document.forms("account").document.all("acct_name").Value= "abc“‘间歇性运行时错误91
发布于 2014-01-10 09:36:11
根据Tim的建议,它的计时问题,您可以添加5秒的延迟,并查看输出。
load:
Do While IE.readystate <> 4: DoEvents: Loop
Application.Wait Now() + TimeSerial(0, 0, 5) ' delay of 5 seconds
Set account = IE.document.getElementById("account_name")
If account Is Nothing Then GoTo load
account.Value = "abc"https://stackoverflow.com/questions/21028042
复制相似问题