首页 > 解决方案 > Vba在html元素上触发'pointerdown'事件

问题描述

作为 excel vba 中网页自动化项目的一部分,需要帮助触发 html 元素上的“pointerdown”事件。

已经能够使用“mousedown”触发器成功地自动化,但最近网页源代码已被修改为使用“pointerdown”来触发而不是“mousedown”。

现有的“mousedown”代码:

Set e1 = IE.Document.createEvent("MouseEvent")
e1.initMouseEvent "mousedown", True, True, 0, 1, 0, 0, 0, 0, True, False, False, False, 0, Null
ElementCol.Item(i).dispatchEvent e1

尝试了以下“pointerdown”代码,但 excel 在 initPointerEvent 行上抛出“Automation error”:

Set e1 = IE.Document.createEvent("PointerEvent")
e1.initPointerEvent "pointerdown", True, True, 0, 1, 0, 0, 0, 0, False, False, False, False, 0, Null , 0, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, False
ElementCol.Item(i).dispatchEvent e1

任何帮助将不胜感激。

标签: excelvbaweb-scrapingautomationmouseevent

解决方案


推荐阅读