excel - 在 URL 中使用 VBA 激活 Onchange 功能
问题描述
我必须使用 excel 在网站内填写表格。该站点的工作方式如下 - 从组合框中选择某些内容时,新的输入框将使用 onchange 函数激活,如下代码所示。
<select name="murat" id="murat" class="normalText" onchange="muratonChange(this);">
function muratonChange(source) {
var muratIndex, Visibility;
muratIndex=source.selectedIndex
document.all.ayaz.style.visibility="visible";
我可以选择组合框中的任何内容。但是,输入框不可见,因此我无法更改它们。使用下面的 vba 代码为组合框赋值
While .Busy Or .readyState < 4: DoEvents: Wend
Do
DoEvents
On Error Resume Next
Set ele = ie.document.querySelector("murat")
On Error GoTo 0
If Timer - t > MAX_WAIT_SEC Then Exit Do
Loop While ele Is Nothing
If Not ele Is Nothing Then
ele.Click
ie.document.getElementsByName("murat")(0).Value = Application.VLookup(Sheets("fener").Range("D3").Text, Sheets("bahce").Range("A:B"), 2, False)
End If
解决方案
首先请发表评论和帮助,而不是编辑我的英语语法来获得徽章等。感谢用户@QHarr。我跟着他的脚步。下面的代码解决了我的问题。
Dim CurrentWindow As HTMLWindowProxy: Set CurrentWindow = ie.document.parentWindow
Call CurrentWindow.execScript("muratonChange(this)")
推荐阅读
- ionic-framework - 离子 - 双击 iPhone 按钮上的图标问题
- c++ - 没有重载函数“strstr”的实例与参数列表匹配
- ssas - 如何在 SSAS (MSBI) 中实现列级安全性?
- php - WooCommerce 和 Wordpress PHP memory_limit 问题
- c - 如何在 free() 函数中转换指针?
- linux - 在 ssh 中递归地从文件中删除前缀
- flutter - 是否可以使用颤振和官方插件处理相机视图中的图像?
- flutter - 使用 {} 表示法分配 Flutter 路由时出错
- python - Python Pandas 分组列而不聚合
- python - 如何更改 Frame 类的大小?