2025-06-14 13:25
excel
excel VBA / HTML 单击下拉列表中的下一页
html<!DOCTYPE html><html><body><select id="mySelect"> <option value="1">选项1</option> <option value="2">选项2</option> <option value="3">选项3</option> <option value="4">选项4</option> <option value="5">选项5</option> <option value="6">选项6</option> <option value="7">选项7</option> <option value="8">选项8</option> <option value="9">选项9</option> <option value="10">选项10</option></select></body></html>
VBASub ClickNextPage() Dim IE As Object Dim doc As Object Dim selectElement As Object Dim nextPageElement As Object ' 创建一个新的Internet Explorer对象 Set IE = CreateObject("InternetExplorer.Application") ' 设置IE窗口为隐藏,以便在后台运行 IE.Visible = False ' 打开HTML文件 IE.navigate "C:\path\to\your\html\file.html" ' 等待页面加载完成 Do While IE.Busy Or IE.readyState <> 4 DoEvents Loop ' 获取HTML文档对象 Set doc = IE.document ' 获取下拉列表元素 Set selectElement = doc.getElementById("mySelect") ' 获取下一页按钮元素 Set nextPageElement = selectElement.NextSibling ' 单击下一页按钮 nextPageElement.Click ' 关闭IE对象 IE.Quit ' 释放对象 Set IE = Nothing Set doc = Nothing Set selectElement = Nothing Set nextPageElement = NothingEnd Sub
navigate
getElementById
Click
关于我们|免责条款|版权声明|侵权举报|隐私政策|联系我们
Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号