自动用日期和日期填充表格

时间:2018-09-18 17:56:19

标签: vba input fetch

我正在尝试通过vba替换Web表在excel中,但是该表没有填充,如果有人帮助,我将不胜感激。谢谢。 下面是我的代码:

Dim strdate As String
Dim eddate As String
Dim obj As Object

Set objie = New InternetExplorer
objie.Visible = True
objie.navigate "https://www.khistocks.com/company-information/company-profile/ABOT.html"

Do While objie.Busy = True Or objie.readyState <> 4: DoEvents: Loop

strdate = Range("B1").Value
eddate = Range("C1").Value
Set obj = objie.Document.getElementById("from")
obj.Value = strdate
obj.Click

Set obj = objie.Document.getElementById("to")
obj.Value = eddate
obj.Click


Application.Wait Now + TimeValue("00:00:03")

objie.Quit
End Sub

下面是网站链接

[网站链接] https://www.khistocks.com/company-information/company-profile/ABOT.html

1 个答案:

答案 0 :(得分:0)

我发现#from和#to字段不接受手动输入。 要解决此问题,只需在设置日期后打开“ datepicker”,然后单击它以执行表更新。 下面的代码对我来说效果很好,请尝试:

Set obj = objie.document.getElementById("to")
obj.Value = eddate
obj.Focus
obj.Click

Set elements = objie.document.getElementsByClassName("ui-datepicker-current-day")

For Each oElement In elements
    oElement.Click
Next oElement