vba - 使用日期自动填充表格
问题描述
我正在尝试在 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
解决方案
我发现 #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
推荐阅读
- python - 将 YAML 键值传递给 Python
- c# - 将字符串作为布尔值从 C# 传递到 PowerShell
- typescript - 如何处理角度 6 中的多个 mat-slide-toggle 标签?
- c - 有没有更好的方法可以在不嵌套这么多 if-else 的情况下根据多个可分性规则检查整数?
- memory-leaks - 使用 WinDbg 对非托管代码进行内存泄漏调试
- javascript - 无法从服务器接收语言文本到客户端
- mysql - 计算整个数据表中 2 个时间戳之间的平均时间值
- php - 在sql中检查值后如何获得响应
- c# - 无法在 C# 中使用 PdfMetamorphosis 捕获异常
- vue.js - 变量类名的语法(或在 v-if 中)