首页 > 解决方案 > 使用日期自动填充表格

问题描述

我正在尝试在 excel 中通过 vba 对 web 表格进行翻页,但表格没有填充,如果有人提供帮助,我将不胜感激。谢谢。下面是我的代码:

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

标签: vbainputfetch

解决方案


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

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

推荐阅读