Manually cycling through VBA Code enters data into web, but clicking button does not

时间:2015-05-12 23:36:10

标签: excel excel-vba vba

Using Excel 2013 to log into a website and change data automatically.

Following Code works perfectly to open the website, enter the User Name and Password, "sign in", and open the next screen.

It should then populate two more boxes on the new screen, but it does not. It generates a RunTime Error saying an "Object is required".

But if I press "Debug" and "step through" from the error line, the Code runs perfectly!

library(lubridate)
df$Time <- hms(df$Time)
df[2] <- df[1] + seconds(10)
head(df, 2)
        Time     Time.1
1 7H 55M 40S 7H 55M 50S
2 7H 55M 50S 7H 55M 60S

All suggestions received gratefully

Ochimus

1 个答案:

答案 0 :(得分:1)

延长等待期以包含.readtState并允许通过消息队列泵进行处理而不是将其锁定。

Do While IE.Busy or ie.readystate <> 4  'READYSTATE_COMPLETE = 4
  doevents
Loop

点击后你也没等。在.Click之后和开始尝试Set个对象之前,将其中一个放在其中。

这应该确保您收到标准页面。如果在满足这两个条件时尚未交付动态内容,则还有其他方法可以实现。